added multimedia support
This commit is contained in:
parent
07e1291fd7
commit
fadcd1be95
|
|
@ -1,4 +1,5 @@
|
|||
/node_modules
|
||||
/bootstrap
|
||||
/public/hot
|
||||
/public/storage
|
||||
/public/uploads
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\MultimediaCategoryRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class MultimediaCategoryCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class MultimediaCategoryCrudController 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;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\MultimediaCategory::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/multimedia-category');
|
||||
CRUD::setEntityNameStrings('category', 'categories');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
CRUD::column('type')->type('select_from_array')->options(['image' => 'Image', 'video' => '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(MultimediaCategoryRequest::class);
|
||||
|
||||
CRUD::field('title');
|
||||
CRUD::field('type')->type('select_from_array')->options(['image' => 'Image', 'video' => 'Video']);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
protected function setupReorderOperation()
|
||||
{
|
||||
// define which model attribute will be shown on draggable elements
|
||||
$this->crud->set('reorder.label', 'title');
|
||||
// define how deep the admin is allowed to nest the items
|
||||
// for infinite levels, set it to 0
|
||||
$this->crud->set('reorder.max_level', 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\MultimediaRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class MultimediaCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class MultimediaCrudController 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\Multimedia::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/multimedia');
|
||||
CRUD::setEntityNameStrings('multimedia', 'multimedia');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('category_id');
|
||||
CRUD::column('title');
|
||||
CRUD::column('media');
|
||||
|
||||
/**
|
||||
* 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(MultimediaRequest::class);
|
||||
|
||||
CRUD::field('category_id');
|
||||
CRUD::field('title');
|
||||
CRUD::field('media')->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();
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class ApiController extends Controller
|
|||
{
|
||||
$this->fractal = new Manager;
|
||||
|
||||
$this->locale = $request->header('X-Localization') ?? 'tm';
|
||||
$this->locale = $request->header('X-Localization') ?? 'en';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ class CategoryController extends ApiController
|
|||
public function index()
|
||||
{
|
||||
$categories = Category::orderBy('lft', 'desc')->get();
|
||||
return $this->respondWithCollection($categories, new CategoryTransformer($this->locale));
|
||||
return $this->respondWithCollection($categories, new CategoryTransformer($this->locale, 'trading'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Api\ApiController;
|
||||
use App\Models\MultimediaCategory;
|
||||
use App\Transformers\CategoryTransformer;
|
||||
|
||||
class MultimediaCategoryController extends ApiController
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$categories = MultimediaCategory::orderBy('lft', 'desc')->get();
|
||||
return $this->respondWithCollection($categories, new CategoryTransformer($this->locale, 'media'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\MultimediaCategory;
|
||||
use App\Transformers\MediaTransformer;
|
||||
|
||||
class MultimediaController extends ApiController
|
||||
{
|
||||
public function index($category)
|
||||
{
|
||||
$medias = MultimediaCategory::where('id', $category)->with('medias')->get()->first()->medias;
|
||||
return $this->respondWithCollection($medias, new MediaTransformer());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ class NewsController extends ApiController
|
|||
{
|
||||
public function index()
|
||||
{
|
||||
$news = News::orderBy('date', 'desc')->paginate(9);
|
||||
$news = News::latest('date')->paginate(9);
|
||||
return $this->respondWithPaginator($news, new NewsTransformer($this->locale));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use App\Models\Category;
|
|||
use App\Models\Group;
|
||||
use App\Models\Trading;
|
||||
use App\Transformers\TradingTransformer;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TradingsController extends ApiController
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class MultimediaCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class MultimediaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreMultimediaCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreMultimediaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateMultimediaCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateMultimediaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ class Document extends Model
|
|||
{
|
||||
$attribute_name = "file";
|
||||
$disk = config('backpack.base.root_disk_name');
|
||||
$destination_path = "public/uploads/files";
|
||||
$destination_path = "public/uploads/documents";
|
||||
|
||||
$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path, $fileName = null);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Multimedia extends Model
|
||||
{
|
||||
use \Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [''];
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(MultimediaCategory::class);
|
||||
}
|
||||
|
||||
public function setMediaAttribute($value)
|
||||
{
|
||||
$attribute_name = "media";
|
||||
$disk = config('backpack.base.root_disk_name');
|
||||
$destination_path = "public/uploads/media";
|
||||
|
||||
$this->uploadFileToDisk($value, $attribute_name, $disk, $destination_path, $fileName = null);
|
||||
|
||||
// return $this->attributes[$attribute_name]; // uncomment if this is a translatable field
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
|
||||
|
||||
class MultimediaCategory extends Model
|
||||
{
|
||||
use \Backpack\CRUD\app\Models\Traits\CrudTrait;
|
||||
use HasFactory;
|
||||
use HasTranslations;
|
||||
|
||||
protected $guarded = [''];
|
||||
public $translatable = ['title'];
|
||||
|
||||
public function medias()
|
||||
{
|
||||
return $this->hasMany(Multimedia::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\MultimediaCategory;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class MultimediaCategoryPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function viewAny(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\MultimediaCategory $multimediaCategory
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function view(User $user, MultimediaCategory $multimediaCategory)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\MultimediaCategory $multimediaCategory
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function update(User $user, MultimediaCategory $multimediaCategory)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\MultimediaCategory $multimediaCategory
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function delete(User $user, MultimediaCategory $multimediaCategory)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\MultimediaCategory $multimediaCategory
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function restore(User $user, MultimediaCategory $multimediaCategory)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\MultimediaCategory $multimediaCategory
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function forceDelete(User $user, MultimediaCategory $multimediaCategory)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Multimedia;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class MultimediaPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function viewAny(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Multimedia $multimedia
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function view(User $user, Multimedia $multimedia)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function create(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Multimedia $multimedia
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function update(User $user, Multimedia $multimedia)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Multimedia $multimedia
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function delete(User $user, Multimedia $multimedia)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Multimedia $multimedia
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function restore(User $user, Multimedia $multimedia)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @param \App\Models\Multimedia $multimedia
|
||||
* @return \Illuminate\Auth\Access\Response|bool
|
||||
*/
|
||||
public function forceDelete(User $user, Multimedia $multimedia)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -8,17 +8,24 @@ use League\Fractal\TransformerAbstract;
|
|||
class CategoryTransformer extends TransformerAbstract
|
||||
{
|
||||
private $locale;
|
||||
private $type;
|
||||
|
||||
public function __construct($locale)
|
||||
public function __construct($locale, $type)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function transform(Category $category)
|
||||
public function transform($category)
|
||||
{
|
||||
return [
|
||||
|
||||
return $this->type == 'trading' ? [
|
||||
'id' => $category->id,
|
||||
'title' => $category->getTranslations('title', [$this->locale])[$this->locale],
|
||||
] : [
|
||||
'id' => $category->id,
|
||||
'title' => $category->getTranslations('title', [$this->locale])[$this->locale],
|
||||
'type' => $category->type,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Multimedia;
|
||||
use Illuminate\Support\Str;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class MediaTransformer extends TransformerAbstract
|
||||
{
|
||||
public function transform(Multimedia $multimedia)
|
||||
{
|
||||
$media = Str::replaceFirst('public/', '', $multimedia->media);
|
||||
return [
|
||||
'id' => $multimedia->id,
|
||||
'title' => $multimedia->title,
|
||||
'media' => url($media),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -3547,30 +3547,30 @@
|
|||
},
|
||||
{
|
||||
"name": "markbaker/matrix",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
||||
"reference": "c66aefcafb4f6c269510e9ac46b82619a904c576"
|
||||
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/c66aefcafb4f6c269510e9ac46b82619a904c576",
|
||||
"reference": "c66aefcafb4f6c269510e9ac46b82619a904c576",
|
||||
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
|
||||
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||
"phpcompatibility/php-compatibility": "^9.3",
|
||||
"phpdocumentor/phpdocumentor": "2.*",
|
||||
"phploc/phploc": "^4.0",
|
||||
"phpmd/phpmd": "2.*",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.3",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||
"sebastian/phpcpd": "^4.0",
|
||||
"squizlabs/php_codesniffer": "^3.4"
|
||||
"squizlabs/php_codesniffer": "^3.7"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
|
|
@ -3597,9 +3597,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
|
||||
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.0"
|
||||
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
|
||||
},
|
||||
"time": "2021-07-01T19:01:15+00:00"
|
||||
"time": "2022-12-02T22:17:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "meilisearch/meilisearch-php",
|
||||
|
|
@ -3891,16 +3891,16 @@
|
|||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "2.63.0",
|
||||
"version": "2.64.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/briannesbitt/Carbon.git",
|
||||
"reference": "ad35dd71a6a212b98e4b87e97389b6fa85f0e347"
|
||||
"reference": "889546413c97de2d05063b8cb7b193c2531ea211"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ad35dd71a6a212b98e4b87e97389b6fa85f0e347",
|
||||
"reference": "ad35dd71a6a212b98e4b87e97389b6fa85f0e347",
|
||||
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/889546413c97de2d05063b8cb7b193c2531ea211",
|
||||
"reference": "889546413c97de2d05063b8cb7b193c2531ea211",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3911,7 +3911,7 @@
|
|||
"symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": "^2.0 || ^3.0",
|
||||
"doctrine/dbal": "^2.0 || ^3.1.4",
|
||||
"doctrine/orm": "^2.7",
|
||||
"friendsofphp/php-cs-fixer": "^3.0",
|
||||
"kylekatarnls/multi-tester": "^2.0",
|
||||
|
|
@ -3989,7 +3989,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-10-30T18:34:28+00:00"
|
||||
"time": "2022-11-26T17:36:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nette/schema",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class MultimediaCategoryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class MultimediaFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMultimediaCategoriesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('multimedia_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->text('title');
|
||||
$table->string('type');
|
||||
$table->integer('parent_id')->default(0)->nullable();
|
||||
$table->integer('lft')->default(0);
|
||||
$table->integer('rgt')->default(0);
|
||||
$table->integer('depth')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('multimedia_categories');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMultimediaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('multimedia', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('multimedia_category_id')->unsigned();
|
||||
$table->foreign('multimedia_category_id')->references('id')->on('multimedia_categories')->onDelete('cascade');
|
||||
$table->text('title')->nullable();
|
||||
$table->text('media');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('multimedia');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MultimediaCategorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MultimediaSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,20 @@
|
|||
{{-- This file is used to store sidebar items, inside the Backpack admin panel --}}
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('dashboard') }}"><i class="la la-home nav-icon"></i> {{ trans('backpack::base.dashboard') }}</a></li>
|
||||
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('category') }}"><i class="nav-icon la la-question"></i> Categories</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('trading') }}"><i class="nav-icon la la-question"></i> Tradings</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('selected-trading') }}"><i class="nav-icon la la-question"></i> Selected tradings</a></li>
|
||||
<li class="nav-item nav-dropdown">
|
||||
<a class="nav-link nav-dropdown-toggle" href="#"><i class="nav-icon la la-users"></i> Tradings</a>
|
||||
<ul class="nav-dropdown-items">
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('category') }}"><i class="nav-icon la la-question"></i> Categories</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('trading') }}"><i class="nav-icon la la-question"></i> Tradings</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('selected-trading') }}"><i class="nav-icon la la-question"></i> Selected tradings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item nav-dropdown">
|
||||
<a class="nav-link nav-dropdown-toggle" href="#"><i class="nav-icon la la-users"></i> Multimedia</a>
|
||||
<ul class="nav-dropdown-items">
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('multimedia-category') }}"><i class="nav-icon la la-question"></i> Categories</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('multimedia') }}"><i class="nav-icon la la-question"></i> Multimedia</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('news') }}"><i class="nav-icon la la-question"></i> News</a></li>
|
||||
<li class='nav-item'><a class='nav-link' href='{{ backpack_url('document') }}'><i class='nav-icon la la-question'></i> Documents</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('tarif') }}"><i class="nav-icon la la-question"></i> Tarifs</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{{ backpack_url('tarif') }}"><i class="nav-icon la la-question"></i> Tarifs</a></li>
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ use App\Http\Controllers\Api\TradingsController;
|
|||
use App\Http\Controllers\Api\NewsController;
|
||||
use App\Http\Controllers\Api\CategoryController;
|
||||
use App\Http\Controllers\Api\DocumentController;
|
||||
use App\Http\Controllers\Api\SelectedTradingController;
|
||||
use App\Http\Controllers\Api\TarifController;
|
||||
use App\Http\Controllers\Api\MultimediaCategoryController;
|
||||
use App\Http\Controllers\Api\MultimediaController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
@ -36,3 +37,6 @@ Route::get('categories/{id}/tradings', [TradingsController::class, 'selectedTrad
|
|||
Route::get('news', [NewsController::class, 'index']);
|
||||
Route::get('documents', [DocumentController::class, 'index']);
|
||||
Route::get('tariffs', [TarifController::class, 'index']);
|
||||
|
||||
Route::get('media/categories', [MultimediaCategoryController::class, 'index']);
|
||||
Route::get('medias/{category}', [MultimediaController::class, 'index']);
|
||||
|
|
|
|||
|
|
@ -23,4 +23,6 @@ Route::group([
|
|||
Route::crud('selected-trading', 'SelectedTradingCrudController');
|
||||
|
||||
Route::crud('tarif', 'TarifCrudController');
|
||||
Route::crud('multimedia-category', 'MultimediaCategoryCrudController');
|
||||
Route::crud('multimedia', 'MultimediaCrudController');
|
||||
}); // this should be the absolute last line of this file
|
||||
Loading…
Reference in New Issue