'name', 'type' => 'text' ], [ 'name' => 'city', 'type' => 'text' ], [ 'name' => 'email', 'type' => 'email' ], [ 'name' => 'is_attending', 'type' => 'select_from_array', 'options' => [ '0' => 'No', '1' => 'Yes' ] ], [ 'name' => 'consent_form', 'type' => 'select_from_array', 'options' => [ '0' => 'No', '1' => 'Yes' ] ], [ 'name' => 'consent_form_second', 'type' => 'select_from_array', 'options' => [ '0' => 'No', '1' => 'Yes' ] ], [ 'name' => 'consent_form_third', 'type' => 'select_from_array', 'options' => [ '0' => 'No', '1' => 'Yes' ] ], [ 'name' => 'attended', 'type' => 'select_from_array', 'options' => [ '0' => 'No', '1' => 'Yes' ] ] ]); /** * Columns can be defined using the fluent syntax or array syntax: * - CRUD::column('price')->type('number'); * - CRUD::addColumn(['name' => 'price', 'type' => 'number']); */ $this->crud->addFilter([ 'name' => 'events', 'type' => 'select2', 'label' => "Event" ], function() { return Event::all()->pluck('name', 'id')->toArray(); }, function($value) { $this->crud->query = $this->crud->query->whereHas('events', function ($query) use ($value) { $query->where('event_id', $value); }); }); $this->crud->addFilter([ 'name' => 'attending', 'type' => 'select2', 'label' => "Will attend" ], function() { return ['0' => 'No', '1' => 'Yes']; }, function($value) { $this->crud->query = $this->crud->query->whereHas('events', function ($query) use ($value) { $query->where('is_attending', $value); }); }); $this->crud->addFilter([ 'name' => 'attended', 'type' => 'select2', 'label' => "Attended" ], function() { return ['0' => 'No', '1' => 'Yes']; }, function($value) { $this->crud->query = $this->crud->query->whereHas('events', function ($query) use ($value) { $query->where('attended', $value); }); }); $this->crud->addFilter([ 'name' => 'consent', 'type' => 'select2', 'label' => "Consent form" ], function() { return ['0' => 'No', '1' => 'Yes']; }, function($value) { $this->crud->query = $this->crud->query->whereHas('events', function ($query) use ($value) { $query->where('consent_form', $value); }); }); $this->crud->enableExportButtons(); } /** * Define what happens when the Create operation is loaded. * * @see https://backpackforlaravel.com/docs/crud-operation-create * @return void */ protected function setupCreateOperation() { CRUD::setValidation(AttenderRequest::class); $this->crud->setFromDb(); /** * Fields can be defined using the fluent syntax or array syntax: * - CRUD::field('price')->type('number'); * - CRUD::addField(['name' => 'price', 'type' => 'number'])); */ } /** * Define what happens when the Update operation is loaded. * * @see https://backpackforlaravel.com/docs/crud-operation-update * @return void */ protected function setupUpdateOperation() { $this->setupCreateOperation(); } }