| Total Complexity | 2 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class ModulesController extends Controller |
||
| 12 | { |
||
| 13 | public function index() |
||
| 14 | { |
||
| 15 | $this->authorize('view-page'); |
||
| 16 | |||
| 17 | $modules = Module::withoutPageSpecific()->orderBy('morph_key')->get()->groupBy('morph_key'); |
||
| 18 | |||
| 19 | return view('chief::back.modules.index', [ |
||
| 20 | 'modules' => $modules, |
||
| 21 | ]); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function store(ModuleCreateRequest $request) |
||
| 25 | { |
||
| 26 | $manager = app(Managers::class)->findByKey($request->module_key); |
||
| 27 | |||
| 28 | $manager->guard('edit'); |
||
| 29 | |||
| 30 | $module = app(CreateModule::class)->handle( |
||
| 31 | $request->get('module_key'), |
||
| 32 | $request->get('slug'), |
||
| 33 | $request->get('page_id') |
||
| 34 | ); |
||
| 35 | |||
| 36 | // Populate the manager with the model so we can direct the admin to the correct page. |
||
| 37 | $manager->manage($module); |
||
| 38 | |||
| 39 | return redirect()->to($manager->route('edit')) |
||
| 40 | ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $manager->details()->title . '" is toegevoegd'); |
||
| 41 | } |
||
| 43 |