public function createFirstUser()
 {
     $request = \Request::instance();
     $method = $request->method();
     if (Verbs::GET === $method) {
         if (!User::adminExists()) {
             $data = ['version' => \Config::get('df.api_version'), 'email' => '', 'name' => '', 'first_name' => '', 'last_name' => ''];
             return view('firstUser', $data);
         } else {
             return redirect()->to('/');
         }
     } else {
         if (Verbs::POST === $method) {
             $data = $request->all();
             $registrar = new Registrar();
             $validator = $registrar->validator($data);
             if ($validator->fails()) {
                 $errors = $validator->getMessageBag()->all();
                 $data = array_merge($data, ['errors' => $errors, 'version' => \Config::get('df.api_version')]);
                 return view('firstUser', $data);
             } else {
                 $registrar->create($data);
                 return redirect()->to('/');
             }
         }
     }
 }
示例#2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     try {
         try {
             if (!User::adminExists()) {
                 $this->runSetup();
             } else {
                 $this->error('Your instance is already setup.');
             }
         } catch (\Exception $e) {
             $this->runSetup();
         }
     } catch (\Exception $e) {
         $this->error($e->getMessage());
     }
 }
 /**
  * @param Request  $request
  * @param \Closure $next
  *
  * @return \Illuminate\Http\RedirectResponse
  * @throws \Exception
  */
 public function handle($request, Closure $next)
 {
     if (!in_array($route = $request->getPathInfo(), ['/setup', '/setup_db'])) {
         try {
             if (!User::adminExists()) {
                 return redirect()->to('/setup');
             }
         } catch (QueryException $e) {
             try {
                 //base table or view not found.
                 \Cache::put('setup_db', true, config('df.default_cache_ttl'));
                 return redirect()->to('/setup_db');
             } catch (\Exception $ex) {
                 throw $ex;
             }
         }
     }
     return $next($request);
 }
 public function createFirstUser()
 {
     if (!User::adminExists()) {
         $request = \Request::instance();
         $method = $request->method();
         if (Verbs::GET === $method) {
             $data = ['version' => \Config::get('df.version'), 'email' => '', 'name' => '', 'first_name' => '', 'last_name' => ''];
             return view('firstUser', $data);
         } else {
             if (Verbs::POST === $method) {
                 $data = $request->all();
                 $user = User::createFirstAdmin($data);
                 if (!$user) {
                     return view('firstUser', $data);
                 }
             }
         }
     }
     return redirect()->to('/');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = $request->getPathInfo();
     if ('/setup' !== $route && '/setup_db' !== $route) {
         try {
             if (!User::adminExists()) {
                 return redirect()->to('/setup');
             }
         } catch (QueryException $e) {
             $code = $e->getCode();
             if ($code === '42S02') {
                 //Mysql base table or view not found.
                 \Cache::put('setup_db', true, config('df.default_cache_ttl'));
                 return redirect()->to('/setup_db');
             } else {
                 throw $e;
             }
         }
     }
     return $next($request);
 }
示例#6
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = $request->getPathInfo();
     if ('/setup' !== $route) {
         try {
             if (!User::adminExists()) {
                 return redirect()->to('/setup');
             }
         } catch (QueryException $e) {
             $code = $e->getCode();
             if ($code === '42S02') {
                 //Mysql base table or view not found.
                 \Artisan::call('migrate');
                 \Artisan::call('db:seed');
                 return redirect()->to('/setup');
             } else {
                 throw $e;
             }
         }
     }
     return $next($request);
 }