Пример #1
0
 public function run($creating = 15)
 {
     foreach ([1, 2] as $accountid) {
         $account = Account::find($accountid);
         $clients = Client::all();
         $users = User::all();
         $users = $users->lists('id')->toArray();
         //flip so we can use array_rand
         $tags = array_flip(Tag::lists('id')->toArray());
         for ($i = 0; $i < $creating; $i++) {
             $project = Modules\Portfolio\Project::create(['account_id' => $account->id, 'date' => $this->nl->dateTimeBetween('-3 months', 'now'), 'website' => $this->nl->url, 'nl' => ['published' => rand(0, 1), 'title' => $this->nl->sentence(2), 'content' => $this->nl->text(1300), 'created_at' => $this->nl->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->nl->dateTimeBetween('-2 months', 'now')], 'fr' => ['published' => rand(0, 1), 'title' => $this->fr->sentence(2), 'content' => $this->fr->text(1300), 'created_at' => $this->fr->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->fr->dateTimeBetween('-2 months', 'now')], 'en' => ['published' => rand(0, 1), 'title' => $this->en->sentence(2), 'content' => $this->en->text(1300), 'created_at' => $this->en->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->en->dateTimeBetween('-2 months', 'now')], 'de' => ['published' => rand(0, 1), 'title' => $this->de->sentence(2), 'content' => $this->de->text(1300), 'created_at' => $this->de->dateTimeBetween('-3 months', 'now'), 'updated_at' => $this->de->dateTimeBetween('-2 months', 'now')]]);
             $this->addImages($project);
             //foreach project we randomly add 1 to 3 collaborators
             $amount = rand(1, 3);
             $possibleUsers = $users;
             for ($j = 0; $j < $amount; $j++) {
                 shuffle($possibleUsers);
                 $add = array_shift($possibleUsers);
                 $project->collaborators()->attach($add);
             }
             $project->tags()->sync(array_rand($tags, 2));
             $project->client()->associate($clients->random());
             $project->save();
         }
     }
 }
Пример #2
0
 /**
  * @return static
  */
 protected function account($name)
 {
     if (env('APP_ENV') == 'production') {
         $account = Account::create(['alias' => $name, 'domain' => "{$name}.be"]);
     } elseif (env('APP_ENV') == 'develop') {
         $account = Account::create(['alias' => '' . $name . '', 'domain' => "dev.{$name}.be"]);
     } else {
         $account = Account::create(['alias' => $name, 'domain' => "{$name}.local"]);
     }
     return $account;
 }
 public function testActivationWillActivateSystemProducts()
 {
     $system = Account::where('alias', 'digiredo')->first();
     list($account, $brand, $category) = $this->baseData();
     $this->products($brand, $system, $category);
     $this->needsActivationCommandsDispatched();
     $catalog = app(CatalogRepositoryInterface::class);
     $gamma = $this->gammaMock($account, $brand, $category);
     $job = new BatchGammaActivation($category, $account, $brand);
     $job->handle($catalog, $gamma);
 }
Пример #4
0
 /**
  * @param int $amount
  */
 public function run($amount = 15)
 {
     foreach ([1, 2] as $accountid) {
         $account = Account::find($accountid);
         //flip array since array_rand returns the keys from an array
         for ($i = 0; $i < $amount; ++$i) {
             $page = $this->model->newInstance($this->texts());
             $page->user_id = 1;
             $page->account_id = $account->id;
             $page->save();
             $this->addImages($page);
             $this->subPages($page, $accountid);
         }
     }
 }
Пример #5
0
 public function run()
 {
     foreach ([1, 2] as $account) {
         $teller = 0;
         $teams = new Collection();
         while ($teller < 3) {
             $teams->push(Team::create(['account_id' => $account, 'nl' => ['name' => $this->faker->sentence(2), 'description' => $this->faker->paragraph(5)], 'en' => ['name' => $this->faker->sentence(2), 'description' => $this->faker->paragraph(5)], 'fr' => ['name' => $this->faker->sentence(2), 'description' => $this->faker->paragraph(5)], 'de' => ['name' => $this->faker->sentence(2), 'description' => $this->faker->paragraph(5)]]));
             $teller++;
         }
         $account = Account::find($account);
         $teams = array_flip($teams->lists('id')->toArray());
         foreach ($account->memberships as $membership) {
             $membership->teams()->attach(array_rand($teams, rand(1, 3)));
         }
     }
 }
Пример #6
0
 protected function seed($prefix)
 {
     $table = ucfirst($prefix) . 'Seeder';
     if (class_exists($table)) {
         if (isset($this->amounts[$prefix])) {
             $this->call($table, $this->amounts[$prefix]);
         } else {
             $this->call($table);
         }
     }
     $accounts = Account::all();
     $modules = Module::all();
     foreach ($accounts as $account) {
         $account->modules()->sync($modules->lists('id')->toArray());
     }
 }
 public function startData()
 {
     $account1 = factory(Account::class)->create();
     $digiredo = Account::find(1);
     $account2 = factory(Account::class)->create();
     $category = factory(Category::class)->create();
     $brand = factory(Brand::class)->create();
     //create 3 products, but all a different account
     factory(Product::class)->create(['brand_id' => $brand->id, 'account_id' => $account1->id]);
     $notSee = factory(Product::class)->create(['brand_id' => $brand->id, 'account_id' => $account2->id]);
     factory(Product::class)->create(['brand_id' => $brand->id, 'account_id' => $digiredo->id]);
     //create notification
     $notification = new GammaNotification(['account_id' => $account1->id, 'brand_id' => $brand->id, 'category_id' => $category->id, 'type' => 'activate']);
     $notification->save();
     return [$category->id, $account1->id, $brand->id, $notification, $notSee];
 }
Пример #8
0
 /**
  * @param int $amount
  */
 public function run($amount = 15)
 {
     foreach ([1, 2] as $accountid) {
         $account = Account::find($accountid);
         $tags = Modules\Tags\Tag::all();
         $tags = $tags->lists('id')->toArray();
         $tags = array_unique($tags);
         //flip array since array_rand returns the keys from an array
         $tags = array_flip($tags);
         for ($i = 0; $i < $amount; ++$i) {
             $post = $this->model->newInstance($this->texts($accountid));
             $post->user_id = 1;
             $post->account_id = $account->id;
             $post->save();
             $this->addImages($post);
             $useTags = array_rand($tags, rand(1, 3));
             $useTags = (array) $useTags;
             $post->tags()->sync($useTags);
         }
     }
 }
Пример #9
0
 protected function productBases($amount)
 {
     $brands = Brand::all();
     $categories = Category::whereNull('original_id')->get();
     $categories->load('synonyms');
     $accounts = Account::take(2)->get();
     foreach ($accounts as $account) {
         for ($i = 0; $i < $amount; $i++) {
             $product = factory(Product::class)->create(['brand_id' => $brands->random(1)->id, 'account_id' => $account->id]);
             $this->addImages($product);
             $category = $categories->random(1);
             $categoryIds = [$category->id];
             if ($category->synonyms) {
                 $categoryIds = array_merge($categoryIds, $category->synonyms->lists('id')->toArray());
             }
             $product->categories()->sync($categoryIds);
             $this->properties($product, $category);
             $this->prices($product, $account->id);
             $this->promotions($product, $account->id);
         }
     }
 }
Пример #10
0
 /**
  *
  */
 protected function account()
 {
     $account = Account::where('alias', env('APP_ALIAS'))->first();
     return $account;
 }
Пример #11
0
 /**
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function handle()
 {
     $membership = new Membership();
     $membership->member()->associate($this->member);
     return $this->account->memberships()->save($membership);
 }