128 lines
4.8 KiB
PHP
128 lines
4.8 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\FolderRequest as StoreRequest;
|
|
use App\Http\Requests\FolderRequest as UpdateRequest;
|
|
use Backpack\CRUD\CrudPanel;
|
|
|
|
/**
|
|
* Class FolderCrudController
|
|
* @package App\Http\Controllers\Admin
|
|
* @property-read CrudPanel $crud
|
|
*/
|
|
class FolderCrudController extends CrudController
|
|
{
|
|
public function setup()
|
|
{
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| CrudPanel Basic Information
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
$this->crud->setModel('App\Models\Folder');
|
|
$this->crud->setRoute(config('backpack.base.route_prefix') . '/folders');
|
|
$this->crud->setEntityNameStrings('Bukja', 'bukjalar');
|
|
$this->crud->orderBy('updated_at', 'DESC');
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| CrudPanel Configuration
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
// TODO: remove setFromDb() and manually define Fields and Columns
|
|
//$this->crud->setFromDb();
|
|
$this->crud->addColumns([
|
|
['label'=>'Bukjanyň ady','name'=>'title','type'=>'text'],
|
|
['label'=>'Mazmuny','name'=>'description','type'=>'ckeditor'],
|
|
]);
|
|
$this->crud->addFields([
|
|
['label'=>'Bukjanyň ady','name'=>'title','type'=>'text'],
|
|
['label'=>'Mazmuny','name'=>'description','type'=>'ckeditor'],
|
|
|
|
//Select
|
|
[
|
|
'label'=>'Eýeçiligiň görnüşi',
|
|
'name'=>'property_id',
|
|
'type'=>'select',
|
|
'entity'=>'property',
|
|
'attribute'=>'title',
|
|
'model'=>'App\Models\PropertyType',
|
|
'option'=>(function($query){
|
|
return $query->orderBy('id','ASC')->get();
|
|
})
|
|
],
|
|
//Select
|
|
[
|
|
'label'=>'Tablisa nirä degişli?',
|
|
'name'=>'usage_name',
|
|
'type'=>'select_from_array',
|
|
'options' => [
|
|
'on_tv' => 'TV',
|
|
'on_radio' => 'Radio',
|
|
'on_belet' => 'Belet',
|
|
'on_aydym' => 'Aýdym.com',
|
|
'on_subtitle' => 'Subtitle',
|
|
'on_web' => 'Website',
|
|
]
|
|
],
|
|
//Total Price
|
|
['label'=>'Umumy bahsy (Total price)','name'=>'total_price','type'=>'text'],
|
|
['label'=>'TV','name'=>'on_tv','type'=>'checkbox'],
|
|
['label'=>'Radio','name'=>'on_radio','type'=>'checkbox'],
|
|
['label'=>'Subtitle','name'=>'on_subtitle','type'=>'checkbox'],
|
|
['label'=>'Web','name'=>'on_web','type'=>'checkbox'],
|
|
['label'=>'Belet','name'=>'on_belet','type'=>'checkbox'],
|
|
['label'=>'Aýdym.com','name'=>'on_aydym','type'=>'checkbox'],
|
|
//checkBox
|
|
['label'=>'Üstüne goşmaça baha goýmalymy?','name'=>'beletli','type'=>'checkbox'],
|
|
['label'=>'Ulanyjy wagt aralygyny saýlamaly.', 'name'=>'choice_time','type'=>'checkbox'],
|
|
//Table
|
|
[
|
|
'Label'=>'Bukjanyň tablisasy',
|
|
'name'=>'folder_table',
|
|
'type'=>'table',
|
|
'entity_singular'=>'option',
|
|
'columns'=>[
|
|
'time'=>'Wagt aralygy',
|
|
'price'=>'Bahasy',
|
|
'set_tv'=>'TV',
|
|
'set_radio'=>'Radio',
|
|
'set_sub'=>'Subtitle',
|
|
'set_web'=>'Web',
|
|
'set_belet'=>'Belet',
|
|
],
|
|
'min'=>'0'
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
// add asterisk for fields that are required in FolderRequest
|
|
$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;
|
|
}
|
|
}
|