hasPermissionTo('clients'))){ $this->crud->denyAccess(['delete', 'update']); } CRUD::setModel(\App\Models\Client::class); CRUD::setRoute(config('backpack.base.route_prefix') . '/client'); CRUD::setEntityNameStrings(trans('app.client.title'), trans('app.client.list_title')); $this->crud->addFilter([ 'name' => 'is_verified', 'type' => 'dropdown', 'label' => trans('app.client.is_verified') ], [ 1 => trans('app.yes'), 0 => trans('app.no'), ], function ($value) { // if the filter is active $this->crud->addClause('where', 'is_verified', $value); }); $this->crud->addFilter([ 'name' => 'is_suspended', 'type' => 'dropdown', 'label' => trans('app.client.is_suspended'), ], [ 1 => trans('app.yes'), 0 => trans('app.no'), ], function ($value) { // if the filter is active $this->crud->addClause('where', 'is_suspended', $value); }); } /** * Define what happens when the List operation is loaded. * * @see https://backpackforlaravel.com/docs/crud-operation-list-entries * @return void */ protected function setupListOperation() { CRUD::addColumns([ ['name' => 'firstname','type'=>'text','label'=> trans('app.client.firstname')], ['name' => 'lastname','type'=>'text','label'=> trans('app.client.lastname')], ['name' => 'email','type'=>'text','label'=> trans('app.client.email')], [ 'name' => 'is_verified', 'type' => 'radio', 'label' => trans('app.client.is_verified'), 'options' => [ 1 => trans('app.yes'), 0 => trans('app.no'), ] ], [ 'name' => 'is_suspended', 'type' => 'radio', 'label' => trans('app.client.is_suspended'), 'options' => [ 1 => trans('app.yes'), 0 => trans('app.no'), ] ] ]); } /** * Define what happens when the Create operation is loaded. * * @see https://backpackforlaravel.com/docs/crud-operation-create * @return void */ protected function setupCreateOperation() { CRUD::setValidation(ClientRequest::class); CRUD::addFields([ ['name' => 'firstname','type'=>'text','label'=> trans('app.client.firstname')], ['name' => 'lastname','type'=>'text','label'=> trans('app.client.lastname')], ['name' => 'email','type'=>'text','label'=> trans('app.client.email')], ['name' => 'is_suspended', 'type' => 'switch', 'label' => trans('app.client.is_suspended')], ['name' => 'is_verified', 'type' => 'switch', 'label' => trans('app.client.is_verified')] ]); } /** * Define what happens when the Update operation is loaded. * * @see https://backpackforlaravel.com/docs/crud-operation-update * @return void */ protected function setupUpdateOperation() { $this->setupCreateOperation(); } public function createClient(Request $request){ $data = $request->only('firstname', 'lastname', 'email', 'password', 'account_id'); $data['is_verified'] = false; $data['is_suspended'] = false; $client = new Client($data); $client->save(); return redirect()->to('/admin/preview/' . $request->account_id . '#users'); } }