first upload all files
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Category\Http\Controllers\Admin;
|
||||
|
||||
use Modules\Category\Entities\Category;
|
||||
use Modules\Admin\Traits\HasCrudActions;
|
||||
use Modules\Category\Http\Requests\SaveCategoryRequest;
|
||||
|
||||
class CategoryController
|
||||
{
|
||||
use HasCrudActions;
|
||||
|
||||
/**
|
||||
* Model for the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Category::class;
|
||||
|
||||
/**
|
||||
* Label of the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label = 'category::categories.category';
|
||||
|
||||
/**
|
||||
* View path of the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $viewPath = 'category::admin.categories';
|
||||
|
||||
/**
|
||||
* Form requests for the resource.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $validation = SaveCategoryRequest::class;
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return Category::with('files')->withoutGlobalScope('active')->find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy resources by given ids.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
Category::withoutGlobalScope('active')
|
||||
->findOrFail($id)
|
||||
->delete();
|
||||
|
||||
return back()->withSuccess(trans('admin::messages.resource_deleted', ['resource' => $this->getLabel()]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Category\Http\Controllers\Admin;
|
||||
|
||||
use Modules\Category\Entities\Category;
|
||||
use Modules\Category\Services\CategoryTreeUpdater;
|
||||
use Modules\Category\Http\Responses\CategoryTreeResponse;
|
||||
|
||||
class CategoryTreeController
|
||||
{
|
||||
/**
|
||||
* Display category tree in json.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$categories = Category::withoutGlobalScope('active')
|
||||
->orderByRaw('-position DESC')
|
||||
->get();
|
||||
|
||||
return new CategoryTreeResponse($categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update category tree in storage.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
CategoryTreeUpdater::update(request('category_tree'));
|
||||
|
||||
return trans('category::messages.category_order_saved');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user