Ejemplo n.º 1
0
 /**
  * @param Tag $tag
  * @param Request $request
  * @return Tag
  * @throws \Exception
  */
 public function update(Tag $tag, Request $request)
 {
     $owner = $this->owner($request);
     $tag->load(['translations']);
     //if the owner didn't contain the tag, we wanted to add it.
     if (!$owner->tags->contains($tag->id)) {
         $this->dispatch(new TagSomething($tag, $owner));
     }
     $this->dispatch(new UpdateTag($tag, translation_input($request, ['name'])));
     return $tag;
 }
Ejemplo n.º 2
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();
         }
     }
 }
Ejemplo n.º 3
0
 public function run()
 {
     foreach ([1, 2] as $account) {
         $tags = ['Design', 'CMS', 'Copy', 'Branding', 'Tutorial', 'Business restructuring', 'Photography', 'Film', 'Analytics'];
         foreach ($tags as $tag) {
             Tag::create(['account_id' => $account, 'nl' => ['name' => $tag], 'fr' => ['name' => $tag], 'en' => ['name' => $tag], 'de' => ['name' => $tag]]);
         }
     }
 }
Ejemplo n.º 4
0
 protected function viewComposers()
 {
     /** @var Factory $view */
     $this->app['view']->composer('Unify::layout.footers.*', function (View $view) {
         $posts = app('cache')->sear('footer-posts:' . app()->getLocale(), function () {
             $translations = PostTranslation::lastPublished()->take(3)->lists('post_id');
             if ($translations->count() == 0) {
                 return new Collection();
             }
             $posts = Post::with(['translations', 'images', 'images.sizes'])->whereIn('posts.id', $translations->toArray())->get();
             return $posts->sortBy('publish_at')->reverse();
         });
         $tweets = latest_tweets();
         $view->with(['posts' => $posts, 'tweets' => $tweets]);
     });
     $this->app['view']->composer('Unify::layout.widgets.clients', function (View $view) {
         $clients = app('cache')->sear('widget-clients', function () {
             return Client::has('images', '>', 0)->take(30)->get();
         });
         if ($clients->count()) {
             $amount = $clients->count() > 10 ? 10 : $clients->count();
             $clients = $clients->shuffle()->random($amount);
         }
         $view->with('clients', $clients);
     });
     $this->app['view']->composer('Unify::blog.sidebars.*', function (View $view) {
         //latest posts ?
         $posts = app('Modules\\Blog\\PostRepositoryInterface');
         $latest = $posts->getLatestPosts(3);
         //problem with this is it can still show tags without content for the current locale
         $tags = \Modules\Tags\Tag::has('content')->limit(15)->get();
         $view->with(['latest' => $latest, 'tags' => $tags]);
     });
     $this->app['view']->composer('Unify::layout.widgets.recent-posts', function (View $view) {
         $posts = app('Modules\\Blog\\PostRepositoryInterface');
         $latest = $posts->getLatestPosts(3);
         $view->with(['latest' => $latest]);
     });
     $this->app['view']->composer('Unify::layout.widgets.portfolio-examples', function (View $view) {
         $projects = app('Modules\\Portfolio\\PortfolioRepositoryInterface');
         $projects = $projects->getExamples(4);
         $view->with(['projects' => $projects]);
     });
 }
Ejemplo n.º 5
0
 public function testShow()
 {
     $this->tryRoute('store.tags.show', [Tag::first()]);
 }
Ejemplo n.º 6
0
 /**
  *
  */
 public function handle()
 {
     $this->tag->fill($this->input);
     return $this->tag->save() ? $this->tag : false;
 }