/** * Store a newly created resource in storage. * * @param Request $request * * @return Response */ public function store(Request $request) { $data = $request->all(); $data['resource'] = $data['controller'] . '@' . $data['method']; $validator = Validator::make($data, $this->getValidationRules()); if ($validator->fails()) { return back()->withInput()->withErrors($validator); } Permission::create($data); return redirect()->action('\\Aginev\\Acl\\Http\\Controllers\\PermissionController@index')->with('success', trans('acl::permission.create.created')); }
/** * Execute the command. * * @return void */ public function handle() { // New permissions $permissions = new Collection(); // Remove not existing permissions Permission::whereNotIn('resource', $this->routes->keys()->toArray())->delete(); foreach ($this->routes as $route) { // Do we have the current permission in the database. If so skip it... $existing_permission = Permission::where('resource', '=', $route['resource'])->first(); if ($existing_permission) { continue; } // Skip some methods $data = $this->getPermissionData($route); if ($data['method'] == 'missingMethod') { continue; } // Add new permission $permissions->push(Permission::create($data)); } $this->assignPermissions($permissions); }