示例#1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Delete the post from database
     $this->post->delete();
     // Fire Event and Listeners
     event(new DeletedPost($this->post));
 }
示例#2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Sanitize the permalink
     $this->permalinkTrait($this->request['permalink']);
     // Create Correct Date and Time Format
     $this->setCreatedAtTime($this->request['date'], $this->request['time']);
     // Renames Directory name if permalink changes
     $this->renameDirectory($this->request['permalink'], $this->post->permalink);
     // Update the post
     $this->post->update($this->request);
     // Update Post Tags
     if (isset($this->request['tag_list'])) {
         $this->post->tags()->sync($this->request['tag_list']);
     } else {
         $this->post->tags()->sync([]);
     }
     event(new SavedPost($this->post, 'updated'));
 }
示例#3
0
 /**
  * Search posts by keywords in posts title
  * 
  * @param  Request $request
  * @return Response
  */
 public function search(Request $request)
 {
     $keywords = $request->get('query');
     if ($keywords !== '') {
         $results = Post::search($keywords) ? Post::search($keywords) : '';
     } else {
         return redirect('/');
     }
     return view('public.search.results', compact('results', 'keywords'));
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('categories', function ($categories) {
         return Category::where('permalink', $categories)->first();
     });
     $router->bind('posts', function ($posts) {
         return Post::where('permalink', $posts)->first();
     });
 }
示例#5
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Change spaces to dashes and lowercase the value
     $this->permalinkTrait($this->request['permalink']);
     // Create Correct Date and Time Format
     $this->setCreatedAtTime($this->request['date'], $this->request['time']);
     // Create Post
     $post = Post::create($this->request);
     // Adds tags to post
     if ($this->tags) {
         $post->tags()->sync($this->tags);
     }
     // Fire the SavedPost Event and Listeners
     event(new SavedPost($post, 'created'));
 }
示例#6
0
 /**
  * Change active post status
  * 
  * @param  integer $id
  * @return Response
  */
 public function status($id)
 {
     $post = Post::where('id', $id)->select('id', 'title', 'active')->first();
     $post->update(['active' => $post->active ? false : true]);
     $action = $post->active ? 'activó' : 'desactivó';
     session()->flash('message', "Se {$action} la publicación \"{$post->title}\" correctamente");
     return redirect()->back();
 }
示例#7
0
 /**
  * Display the posts sitemap
  *
  * @return \Illuminate\Http\Response
  */
 public function posts()
 {
     $posts = Post::orderBy('created_at', 'desc')->select(['created_at', 'permalink'])->get();
     return Response::view('public/sitemap/posts', ['posts' => $posts], 200, ['Content-Type' => 'text/xml; charset=UTF-8']);
 }
示例#8
0
 /**
  * Get posts for feeds
  * 
  * @return Response XML
  */
 public function posts()
 {
     $data['posts'] = Post::postsFeeds();
     return Response::view('public/feeds/posts', $data, 200, ['Content-Type' => 'application/atom+xml; charset=UTF-8']);
 }
示例#9
0
 /**
  * Display post details
  *
  * @param  string $permalink
  * @param  Request $request
  * @return Response
  */
 public function postDetails($permalink, Request $request)
 {
     $variables = ['post' => Post::details($permalink)->with('tags')->first(), 'page' => 'blog', 'categories' => Category::PostsCategories(), 'tags' => Tag::PostTags(), 'sponsors' => Sponsor::PublicSponsors(), 'path' => $request->segments()];
     return view('public.blog.post-details', $variables);
 }