Advertisement
Guest User

Untitled

a guest
Feb 12th, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Dashboard;
  4.  
  5. use App\Http\Requests\CreateNomenclatureRequest;
  6. use App\Models\ModelNomenclature;
  7. use Illuminate\Http\Request;
  8. use App\Http\Controllers\Controller;
  9.  
  10. class ControllerNomenclature extends Controller
  11. {
  12.     protected $nomenclature;
  13.  
  14.     public function __construct(ModelNomenclature $nomenclature)
  15.     {
  16.         $this->nomenclature = $nomenclature;
  17.     }
  18.  
  19.     //Возвращаем разные view, зависит от запроса.
  20.     public function index()
  21.     {
  22.         $nomenclature = $this->nomenclature->getMainNomenclatureLevel();
  23.         $view = request()->ajax() ? 'ajax' : 'index';
  24.  
  25.         return view("backend.dashboard.nomenclature.$view", compact('nomenclature'));
  26.     }
  27.  
  28.     //Создаем запись в номенклатуре и возвращаем partial view.
  29.     public function create(CreateNomenclatureRequest $request)
  30.     {
  31.         $this->nomenclature->produce($request->all());
  32.         return $this->index();
  33.     }
  34.  
  35.     //Удаляем записи из номенклатуры и возвращаем partial view..
  36.     public function delete(Request $request)
  37.     {
  38.         $this->nomenclature->deleteItems($request->all());
  39.         return $this->index();
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement