Пример #1
0
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $postId) {
             if (!($post = Post::find($postId)) || !$post->canEdit($this->user)) {
                 continue;
             }
             $post->delete();
         }
         Flash::success('Successfully deleted those posts.');
     }
     return $this->listRefresh();
 }
Пример #2
0
 /**
  * Returns the URL for the master object of given ID
  *
  * @param  MenuItem  $item Master object iD
  *
  * @return string
  */
 public function getUrl(MenuItem $item)
 {
     $page_url = Settings::get('blog_post_page', 'blog/post');
     $post = Post::find($item->master_object_id);
     if (!$post) {
         throw new ApplicationException("Post not found.");
     }
     return URL::to($page_url . '/' . $post->slug);
 }
Пример #3
0
 protected function findDuplicatePost($data)
 {
     if ($id = array_get($data, 'id')) {
         return Post::find($id);
     }
     $title = array_get($data, 'title');
     $post = Post::where('title', $title);
     if ($slug = array_get($data, 'slug')) {
         $post->orWhere('slug', $slug);
     }
     return $post->first();
 }