コード例 #1
0
ファイル: UserTableSeeder.php プロジェクト: bitller/nova
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(App\QuestionCategory::class)->create(['name' => 'first category']);
     factory(App\QuestionCategory::class)->create(['name' => 'second category']);
     // Generate users
     factory(App\User::class, 2)->create()->each(function ($user) {
         // Generate trial period
         \App\UserTrialPeriod::create(['user_id' => $user->id, 'trial_period_id' => \App\TrialPeriod::first()->id]);
         // Settings
         $user->settings()->save(factory(App\UserSetting::class)->make(['user_id' => $user->id, 'language_id' => 1]));
         // Generate notifications
         $notifications = \App\Notification::all();
         foreach ($notifications as $notification) {
             $user->notifications()->save(factory(\App\UserNotification::class)->make(['user_id' => $user->id, 'notification_id' => $notification->id]));
         }
         // Bills per user
         $rows = 12;
         // Products per bill
         $productsPerBill = 5;
         for ($i = 0; $i < $rows; $i++) {
             // Generate client
             $client = $user->clients()->save(factory(App\Client::class)->make());
             // Generate bill for that client
             $bill = $user->bills()->save(factory(App\Bill::class)->make(['client_id' => $client->id]));
             // Generate products
             for ($j = 0; $j < $productsPerBill; $j++) {
                 $product = $user->products()->save(factory(App\Product::class)->make());
                 $bill->products()->save(factory(App\BillProduct::class)->make(['product_id' => $product->id]));
                 $applicationProduct = factory(App\ApplicationProduct::class)->create();
                 $bill->applicationProducts()->save(factory(App\BillApplicationProduct::class)->make(['product_id' => $applicationProduct->id]));
             }
         }
     });
 }
コード例 #2
0
ファイル: RegisterController.php プロジェクト: bitller/nova
 /**
  * Create new account.
  *
  * @param CreateAccountRequest $request
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function register(CreateAccountRequest $request)
 {
     $response = new AjaxResponse();
     $roles = new Roles();
     // Build user data array
     $data = ['email' => $request->get('email'), 'password' => bcrypt($request->get('password')), 'role_id' => $roles->getUserRoleId()];
     // Insert user
     $user = User::create($data);
     // User settings
     UserSetting::insert(['user_id' => $user->id, 'language_id' => Settings::defaultLanguageId()]);
     // Create trial period
     UserTrialPeriod::create(['user_id' => $user->id, 'trial_period_id' => TrialPeriod::where('validity_days', 90)->first()->id]);
     Auth::login($user);
     $response->setSuccessMessage(trans('register.account_created'));
     return response($response->get());
 }
コード例 #3
0
ファイル: GenerateAdmin.php プロジェクト: bitller/nova
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $roles = new Roles();
     $user = new User();
     $user->first_name = $this->argument('first_name');
     $user->last_name = $this->argument('last_name');
     $user->email = $this->argument('email');
     $user->password = bcrypt($this->argument('password'));
     $user->role_id = $roles->getAdminRoleId();
     $user->save();
     // Settings
     $settings = new UserSetting();
     $settings->user_id = $user->id;
     $settings->language_id = 2;
     $settings->save();
     // Trial period
     UserTrialPeriod::create(['user_id' => $user->id, 'trial_period_id' => TrialPeriod::first()->id]);
     $this->info('User with admin privileges was generated');
 }