2022-12-07 06:04:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
use App\Http\Requests\VideoRequest;
|
|
|
|
|
use App\Models\Video;
|
|
|
|
|
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
|
|
|
|
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class VideoCrudController
|
|
|
|
|
* @package App\Http\Controllers\Admin
|
|
|
|
|
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
|
|
|
|
*/
|
|
|
|
|
class VideoCrudController extends CrudController
|
|
|
|
|
{
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
|
|
|
|
use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configure the CrudPanel object. Apply settings to all operations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function setup()
|
|
|
|
|
{
|
|
|
|
|
CRUD::setModel(\App\Models\Video::class);
|
|
|
|
|
CRUD::setRoute(config('backpack.base.route_prefix') . '/video');
|
2022-12-08 05:58:29 +00:00
|
|
|
CRUD::setEntityNameStrings(trans('backpack::model.video'), trans('backpack::model.videos'));
|
2022-12-07 06:04:13 +00:00
|
|
|
if(count(\App\Models\Video::all()) > 0){
|
|
|
|
|
$this->crud->denyAccess('create');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the List operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupListOperation()
|
|
|
|
|
{
|
|
|
|
|
CRUD::column('title');
|
2023-03-03 12:21:45 +00:00
|
|
|
CRUD::column('image')->type('image');
|
2022-12-07 06:04:13 +00:00
|
|
|
CRUD::column('video');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Columns can be defined using the fluent syntax or array syntax:
|
|
|
|
|
* - CRUD::column('price')->type('number');
|
|
|
|
|
* - CRUD::addColumn(['name' => 'price', 'type' => 'number']);
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define what happens when the Create operation is loaded.
|
|
|
|
|
*
|
|
|
|
|
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function setupCreateOperation()
|
|
|
|
|
{
|
|
|
|
|
CRUD::setValidation(VideoRequest::class);
|
|
|
|
|
|
|
|
|
|
CRUD::field('title');
|
2023-03-03 12:21:45 +00:00
|
|
|
CRUD::field('image')->type('image');
|
2022-12-07 06:04:13 +00:00
|
|
|
CRUD::field('video')->type('upload')->upload(true);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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();
|
|
|
|
|
}
|
|
|
|
|
}
|