示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user = Auth::getUser();
     $input = Request::all();
     $org = Organisation::create($input);
     $result = DB::table('organisation_user')->insertGetId(array('organisation_id' => $org->id, 'user_id' => $user->id, 'owner_id' => true));
     //return redirect('/dashboard/' . $org->id);
     return redirect('/dashboard/');
 }
示例#2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $organisation = Organisation::create(['name' => $data['organisationName']]);
     $role = Role::whereName('owner')->first();
     $userOrganisationRole = new UserOrganisationRole(['user_id' => $user->id, 'organisation_id' => $organisation->id, 'role_id' => $role->id]);
     $user->organisationRoles()->save($userOrganisationRole);
     return $user;
 }