|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace {{namespace}}; |
| 4 | + |
| 5 | +use {{rootNamespace}}Http\Requests; |
| 6 | +use {{rootNamespace}}Models\{{model}}; |
| 7 | +use Illuminate\Http\Request; |
| 8 | +use {{rootNamespace}}Http\Controllers\Admin\AdminController; |
| 9 | + |
| 10 | +class {{class}} extends AdminController |
| 11 | +{ |
| 12 | + /** |
| 13 | + * Display a listing of {{resource}}. |
| 14 | + * |
| 15 | + * @return $this |
| 16 | + */ |
| 17 | + public function index() |
| 18 | + { |
| 19 | + save_resource_url(); |
| 20 | + |
| 21 | + return $this->view('{{viewPath}}.index')->with('items', {{model}}::all()); |
| 22 | + } |
| 23 | + |
| 24 | + /** |
| 25 | + * Show the form for creating a new {{resource}}. |
| 26 | + * |
| 27 | + * @return $this |
| 28 | + */ |
| 29 | + public function create() |
| 30 | + { |
| 31 | + return $this->view('{{viewPath}}.create_edit'); |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * Store a newly created {{resource}} in storage. |
| 36 | + * |
| 37 | + * @return $this |
| 38 | + */ |
| 39 | + public function store() |
| 40 | + { |
| 41 | + $attributes = request()->validate({{model}}::$rules, {{model}}::$messages); |
| 42 | + |
| 43 | + ${{resource}} = $this->createEntry({{model}}::class, $attributes); |
| 44 | + |
| 45 | + return redirect_to_resource(); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Display the specified {{resource}}. |
| 50 | + * |
| 51 | + * @param {{model}} ${{resource}} |
| 52 | + * @return $this |
| 53 | + */ |
| 54 | + public function show({{model}} ${{resource}}) |
| 55 | + { |
| 56 | + return $this->view('{{viewPath}}.show')->with('item', ${{resource}}); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Show the form for editing the specified {{resource}}. |
| 61 | + * |
| 62 | + * @param {{model}} ${{resource}} |
| 63 | + * @return $this |
| 64 | + */ |
| 65 | + public function edit({{model}} ${{resource}}) |
| 66 | + { |
| 67 | + return $this->view('{{viewPath}}.create_edit')->with('item', ${{resource}}); |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * Update the specified {{resource}} in storage. |
| 72 | + * |
| 73 | + * @param {{model}} ${{resource}} |
| 74 | + * @return $this |
| 75 | + */ |
| 76 | + public function update({{model}} ${{resource}}) |
| 77 | + { |
| 78 | + $attributes = request()->validate({{model}}::$rules, {{model}}::$messages); |
| 79 | + |
| 80 | + ${{resource}} = $this->updateEntry(${{resource}}, $attributes); |
| 81 | + |
| 82 | + return redirect_to_resource(); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Remove the specified {{resource}} from storage. |
| 87 | + * |
| 88 | + * @param {{model}} ${{resource}} |
| 89 | + * @return $this |
| 90 | + */ |
| 91 | + public function destroy({{model}} ${{resource}}) |
| 92 | + { |
| 93 | + $this->deleteEntry(${{resource}}, request()); |
| 94 | + |
| 95 | + return redirect_to_resource(); |
| 96 | + } |
| 97 | +} |
0 commit comments