コード例 #1
0
 public function index(Request $request)
 {
     $tag = $request->get('tag');
     $data = $this->dispatch(new BlogIndexData($tag));
     $layout = $tag ? Tag::layout($tag) : 'welcome';
     return view($layout, $data);
 }
コード例 #2
0
ファイル: Post.php プロジェクト: ReyRodriguez/kuento
 public function syncTags(array $tags)
 {
     Tag::addNeededTags($tags);
     if (count($tags)) {
         $this->tags()->sync(Tag::whereIn('tag', $tags)->lists('id')->all());
         return;
     }
     $this->tags()->detach();
 }
コード例 #3
0
 /**
  * @param $slug
  * @return mixed
  */
 public function showPost($slug, Request $request)
 {
     $post = Post::with('tags')->whereSlug($slug)->firstOrFail();
     $tag = $request->get('tag');
     if ($tag) {
         $tag = Tag::whereTag($tag)->firstOrFail();
     }
     return view($post->layout, compact('post', 'tag', 'slug'));
 }
コード例 #4
0
ファイル: BlogIndexData.php プロジェクト: ReyRodriguez/kuento
 /**
  * Return data for a tag index page
  *
  * @param string $tag
  * @return array
  */
 protected function tagIndexData($tag)
 {
     $tag = Tag::where('tag', $tag)->firstOrFail();
     $reverse_direction = (bool) $tag->reverse_direction;
     $posts = Post::where('published_at', '<=', Carbon::now())->whereHas('tags', function ($q) use($tag) {
         $q->where('tag', '=', $tag->tag);
     })->where('is_draft', 0)->orderBy('published_at', $reverse_direction ? 'asc' : 'desc')->simplePaginate(config('blog.posts_per_page'));
     $posts->addQuery('tag', $tag->tag);
     $page_image = $tag->page_image ?: config('blog.page_image');
     return ['title' => $tag->title, 'subtitle' => $tag->subtitle, 'posts' => $posts, 'page_image' => $page_image, 'tag' => $tag, 'reverse_direction' => $reverse_direction, 'meta_description' => $tag->meta_description ?: \config('blog.description')];
 }
コード例 #5
0
 /**
  * Execute the command.
  *
  * @return array of fieldnames => values
  */
 public function handle()
 {
     $fields = $this->fieldList;
     if ($this->id) {
         $fields = $this->fieldsFromModel($this->id, $fields);
     } else {
         $when = Carbon::now()->addHour();
         $fields['publish_date'] = $when->format('M-j-Y');
         $fields['publish_time'] = $when->format('g:i A');
     }
     foreach ($fields as $fieldName => $fieldValue) {
         $fields[$fieldName] = old($fieldName, $fieldValue);
     }
     return array_merge($fields, ['allTags' => Tag::lists('tag')->all()]);
 }
コード例 #6
0
ファイル: TagController.php プロジェクト: ReyRodriguez/kuento
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $tag->delete();
     return redirect('/admin/tag')->withSuccess("The '{$tag->tag}' tag has been deleted.");
 }