/** * Run the database seeds. * * @return void */ public function run() { $superUser = User::firstOrCreate(['first_name' => 'SUPER', 'last_name' => 'ADMIN', 'email' => '*****@*****.**']); $superUser->update(['password' => bcrypt('secret')]); $adminRole = Role::whereName('SUPER')->first(); UserRole::firstOrCreate(['user_id' => $superUser->id, 'role_id' => $adminRole->id]); factory(User::class, 100)->create()->each(function ($user) { //$user->posts()->save(factory(App\Post::class)->make()); }); }
/** * Store a newly created resource in storage. * * @param Requests\CreateRequest $request * * @return \Illuminate\Http\Response */ public function store(Requests\CreateRequest $request) { $role = $this->role->create($request->all()); return response()->json($role); }
/** * Run the database seeds. * * @return void */ public function run() { Role\Role::firstOrCreate(['name' => 'SUPER']); Role\Role::firstOrCreate(['name' => 'ADMIN']); Role\Role::firstOrCreate(['name' => 'EDITOR']); }