public function run() { DB::table('user_types')->delete(); UserType::create(['id' => 1, 'name' => 'Site Administrator', 'level' => UserType::SITE_ADMIN_LEVEL]); UserType::create(['id' => 2, 'name' => 'Church Administrator', 'level' => UserType::ORG_ADMIN_LEVEL]); UserType::create(['id' => 3, 'name' => 'Church User', 'level' => UserType::ORG_USER_LEVEL]); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $obj = new $this->model(); $obj->fill(empty_to_null(Input::all())); $obj::requirePassword(); // TODO more security around this: check by user org if (!$obj->organization_id) { $obj->user_type_id = UserType::whereLevel(UserType::SITE_ADMIN_LEVEL)->get()[0]->id; } else { if (1 == $obj->user_type_id) { return Response::make('Unauthorized', 401); } } $obj->save(); if ($obj->errors()->any()) { return Redirect::route($this->modelName . '.create')->withInput()->withErrors($obj->errors()); } $flash = 'Your user has been created.'; // if( $obj->organization ) { // return Redirect::route( 'organizations.show', $obj->organization->uid ) // ->with('myflash', $flash); // } else { return Redirect::route($this->modelName . '.index')->with('myflash', $flash); //} }