Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers\Dashboard;
- use App\Http\Requests\CreateNomenclatureRequest;
- use App\Models\ModelNomenclature;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class ControllerNomenclature extends Controller
- {
- protected $nomenclature;
- public function __construct(ModelNomenclature $nomenclature)
- {
- $this->nomenclature = $nomenclature;
- }
- //Возвращаем разные view, зависит от запроса.
- public function index()
- {
- $nomenclature = $this->nomenclature->getMainNomenclatureLevel();
- $view = request()->ajax() ? 'ajax' : 'index';
- return view("backend.dashboard.nomenclature.$view", compact('nomenclature'));
- }
- //Создаем запись в номенклатуре и возвращаем partial view.
- public function create(CreateNomenclatureRequest $request)
- {
- $this->nomenclature->produce($request->all());
- return $this->index();
- }
- //Удаляем записи из номенклатуры и возвращаем partial view..
- public function delete(Request $request)
- {
- $this->nomenclature->deleteItems($request->all());
- return $this->index();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement