/** * @param Request $request * @param Post $post */ public function batchUnpublish(Request $request, Post $post) { $ids = $request->get('posts', []); if (is_array($ids) && count($ids)) { $posts = $post->whereIn('posts.id', $ids)->get(); foreach ($posts as $post) { $translation = $post->translate($request->get('locale')); if ($translation) { $translation->publish_at = null; } $translation->save(); } } }
/** * * $newsletter */ protected function getMaps() { $posts = new Collection(); $projects = new Collection(); $this->each(function ($widget) use($projects, $posts) { if ($widget->resource) { if ($widget->resource_type == Post::class) { $posts->push($widget->resource_id); } if ($widget->resource_type == Project::class) { $projects->push($widget->resource_id); } } if ($widget->other_resource) { if ($widget->other_resource_type == Post::class) { $posts->push($widget->other_resource_id); } if ($widget->other_resource_type == Project::class) { $projects->push($widget->other_resource_id); } } }); $posts = Post::whereIn('posts.id', $posts->all())->with(['translations', 'images', 'images.sizes'])->get(); $projects = Project::whereIn('portfolio_projects.id', $projects->all())->with(['translations', 'images', 'images.sizes'])->get(); return [$posts, $projects]; }