/** * @param Request $request * @param Project $project */ public function batchUnpublish(Request $request, Project $project) { $ids = $request->get('projects', []); if (is_array($ids) && count($ids)) { $projects = $project->whereIn('portfolio_projects.id', $ids)->get(); foreach ($projects as $project) { $translation = $project->translate($request->get('locale')); if ($translation) { $translation->published = false; } $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]; }