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(); }
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(); }