public function run() { \App\Model\Groups::create(['name' => "Yƶnetici", 'status' => 1]); \App\Model\Groups::create(['name' => "Editor", 'status' => 1]); \App\Model\GroupPerms::create(['group_id' => 1, 'controller' => null, 'action' => null]); $user = new \App\User(); $user->name = "John"; $user->surname = "DOE"; $user->email = "*****@*****.**"; $user->password = bcrypt("admin"); $user->status = 1; $user->save(); \App\Model\UserGroup::create(['user_id' => 1, 'group_id' => 1]); }
public function run() { \App\Model\Groups::create(['name' => "SuperAdmin", 'status' => 1]); \App\Model\Groups::create(['name' => "Editor", 'status' => 1]); \App\Model\GroupPerms::create(['group_id' => 1, 'controller' => null, 'action' => null]); $user = new \App\User(); $user->name = "Ertil"; $user->surname = "Gani"; $user->email = "*****@*****.**"; $user->password = bcrypt("admin"); $user->status = 1; $user->save(); \App\Model\UserGroup::create(['user_id' => 1, 'group_id' => 1]); \App\Model\Report::create(['website_id' => 1, 'user_id' => 1]); }
public function postPerms($id, Request $request) { $group = Groups::where('id', '=', $id)->live()->firstOrFail(); if ($request->input('allperms') == "1") { GroupPerms::where("group_id", "=", $group->id)->delete(); // remove all records GroupPerms::create(['group_id' => $group->id, 'controller' => null, 'action' => null]); } elseif (!is_array($request->input('perms'))) { GroupPerms::where("group_id", "=", $group->id)->delete(); // remove all records } else { $currentPerms = []; foreach (GroupPerms::where('group_id', '=', $group->id)->get() as $row => $p) { $controllername = strlen($p->controller) < 1 ? "all" : $p->controller; $actionname = strlen($p->action) < 1 ? "all" : $p->action; $currentPerms[$controllername . "___" . $actionname] = $p->id; } $postperms = $request->input('perms'); if (is_array($postperms)) { foreach ($postperms as $r => $perm) { if (isset($currentPerms[$perm])) { unset($currentPerms[$perm]); } else { $str = explode('___', $perm); if ($str[0] == "all") { $str[0] = null; } if ($str[1] == "allmethods") { $str[1] = null; } GroupPerms::create(['group_id' => $group->id, 'controller' => $str[0], 'action' => $str[1]]); } } GroupPerms::whereIn('id', array_values($currentPerms))->delete(); } } return redirect('settings/groups/data/perms/' . $group->id)->with('custom_success', trans('app.perms') . trans('app.successfully_saved')); }