73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Shop;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Repositories\Shop\Merchandises;
|
|
use App\Repositories\Shop\Producers;
|
|
use App\Repositories\Shop\TagGroups;
|
|
use App\Datatables\Shop\MerchandisesDataTable;
|
|
|
|
use App\Models\Shop\Merchandise;
|
|
|
|
class MerchandiseController extends Controller
|
|
{
|
|
public function index(MerchandisesDataTable $dataTable)
|
|
{
|
|
return $dataTable->render('Admin.Shop.Merchandises.list');
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
$data['producers_list'] = Producers::getOptions();
|
|
$data['tags_list'] = TagGroups::getTreeTags();
|
|
return view('Admin.Shop.Merchandises.create', $data);
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$data = $request->all();
|
|
Merchandises::storeFull($data);
|
|
return redirect()->route('Admin.Shop.Merchandises.index');
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
return view('Admin.Shop.Merchandises.view', Merchandises::get($id));
|
|
}
|
|
|
|
public function edit($id)
|
|
{
|
|
$data['merchandise'] = Merchandises::getFull($id);
|
|
$data['producers_list'] = Producers::getOptions();
|
|
$data['tags_list'] = TagGroups::getTreeTags();
|
|
return view('Admin.Shop.Merchandises.edit', $data);
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
return Merchandises::destroy($id);
|
|
}
|
|
|
|
public function getImages(Request $request, $id = false, $can_edit = true)
|
|
{
|
|
$id = $id ? $id : $request->input('id');
|
|
$data['images'] = Merchandises::getImages($id);
|
|
$data['can_edit'] = $can_edit;
|
|
return view('components.uploader.mini-gallery-items', $data);
|
|
}
|
|
|
|
public function deleteImage(Request $request)
|
|
{
|
|
$id = $request->input('id');
|
|
$index = $request->input('index');
|
|
return Merchandises::deleteImage($id, $index);
|
|
}
|
|
|
|
public function exportExcel()
|
|
{
|
|
return Merchandises::exportExcel();
|
|
}
|
|
}
|