-
app/Http/Controllers/PostController.php
Open in GitHubuse App\Events\PostViewEvent; use App\Models\Post; use RealRashid\SweetAlert\Facades\Alert; class PostController extends Controller { // public function show($id) { $post = Post::findOrFail($id); event(new PostViewEvent($post)); $company = $post->company()->first(); $similarPosts = Post::whereHas('company', function ($query) use ($company) { return $query->where('company_category_id', $company->company_category_id); })->where('id', '<>', $post->id)->with('company')->take(5)->get(); return view('post.show')->with([ 'post' => $post, 'company' => $company, 'similarJobs' => $similarPosts ]); } // |