90 lines
3.5 KiB
PHP
90 lines
3.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\TopheaderadvRequest as StoreRequest;
|
|
use App\Http\Requests\TopheaderadvRequest as UpdateRequest;
|
|
use Backpack\CRUD\CrudPanel;
|
|
|
|
/**
|
|
* Class TopheaderadvCrudController
|
|
* @package App\Http\Controllers\Admin
|
|
* @property-read CrudPanel $crud
|
|
*/
|
|
class TopheaderadvCrudController extends CrudController
|
|
{
|
|
public function setup()
|
|
{
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| CrudPanel Basic Information
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
$this->crud->setModel('App\Models\Topheaderadv');
|
|
$this->crud->setRoute(config('backpack.base.route_prefix') . '/topheaderadv');
|
|
$this->crud->setEntityNameStrings('topheaderadv', 'topheaderadvs');
|
|
$this->crud->orderBy('updated_at', 'DESC');
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| CrudPanel Configuration
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
// TODO: remove setFromDb() and manually define Fields and Columns
|
|
//$this->crud->setFromDb();
|
|
|
|
$this->crud->addColumns([
|
|
['name' => 'page_id', 'type' => 'select', 'entity' => 'page', 'attribute' =>'title', 'model' => 'App\Models\Page',
|
|
'lable'=>'Page'],
|
|
['name' => 'img_url','type' => 'text', 'lable' => 'Image'],
|
|
['name' => 'bottom_img_url','type' => 'text', 'lable' => 'Ashaky adv'],
|
|
['name' => 'home','type' => 'boolean', 'lable' => 'Home'],
|
|
]);
|
|
|
|
$this->crud->addFields([
|
|
['name' => 'page_id', 'type' => 'select', 'entity' => 'page', 'attribute' =>'title', 'model' => 'App\Models\Page',
|
|
'lable'=>'Page'],
|
|
['name' => 'url_top','type' => 'text', 'lable' => 'Url top'],
|
|
[ // image
|
|
'label' => "Yokardaky reklama (2076 x 90)",
|
|
'name' => "img_url",
|
|
'type' => 'browse'],
|
|
['name' => 'alt_top','type' => 'text', 'lable' => 'Alt top'],
|
|
['name' => 'url_bottom','type' => 'text', 'lable' => 'Url bottom'],
|
|
[ // image
|
|
'label' => "Ashaky Reklama",
|
|
'name' => "bottom_img_url",
|
|
'type' => 'browse'],
|
|
['name' => 'alt_bottom','type' => 'text', 'lable' => 'Alt bottom'],
|
|
['name' => 'home','type' => 'checkbox', 'lable' => 'Home'],
|
|
|
|
]);
|
|
|
|
// add asterisk for fields that are required in TopheaderadvRequest
|
|
$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;
|
|
}
|
|
}
|