71 lines
2.5 KiB
PHP
71 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
|
|
// VALIDATION: change the requests to match your own file names if you need form validation
|
|
use App\Http\Requests\GurnawRequest as StoreRequest;
|
|
use App\Http\Requests\GurnawRequest as UpdateRequest;
|
|
use Backpack\CRUD\CrudPanel;
|
|
|
|
/**
|
|
* Class GurnawCrudController
|
|
* @package App\Http\Controllers\Admin
|
|
* @property-read CrudPanel $crud
|
|
*/
|
|
class GurnawCrudController extends CrudController
|
|
{
|
|
public function setup()
|
|
{
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| CrudPanel Basic Information
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
$this->crud->setModel('App\Models\Gurnaw');
|
|
$this->crud->setRoute(config('backpack.base.route_prefix') . '/gurnawlar');
|
|
$this->crud->setEntityNameStrings('Gurnaw', 'Gurnawlar');
|
|
$this->crud->orderBy('updated_at', 'DESC');
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| CrudPanel Configuration
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
// TODO: remove setFromDb() and manually define Fields and Columns
|
|
// $this->crud->setFromDb();
|
|
$this->crud->addColumns([
|
|
['label'=>'Gurnawyň ady','name'=>'title','type'=>'text'],
|
|
['label'=>'Mazmuny','name'=>'description','type'=>'ckeditor']
|
|
]);
|
|
$this->crud->addFields([
|
|
['label'=>'Gurnawyň ady','name'=>'title','type'=>'text'],
|
|
['label'=>'Mazmuny','name'=>'description','type'=>'ckeditor']
|
|
]);
|
|
|
|
// add asterisk for fields that are required in GurnawRequest
|
|
$this->crud->setRequiredFields(StoreRequest::class, 'create');
|
|
$this->crud->setRequiredFields(UpdateRequest::class, 'edit');
|
|
}
|
|
|
|
public function store(StoreRequest $request)
|
|
{
|
|
// your additional operations before save here
|
|
$redirect_location = parent::storeCrud($request);
|
|
// your additional operations after save here
|
|
// use $this->data['entry'] or $this->crud->entry
|
|
return $redirect_location;
|
|
}
|
|
|
|
public function update(UpdateRequest $request)
|
|
{
|
|
// your additional operations before save here
|
|
$redirect_location = parent::updateCrud($request);
|
|
// your additional operations after save here
|
|
// use $this->data['entry'] or $this->crud->entry
|
|
return $redirect_location;
|
|
}
|
|
}
|