consulta dues taules inner join al controlador
Created at: 2022-11-13 18:30:12 | Updated at: 2024-08-28 06:08:24
1/** app\Http\Controllers\BlogPostsController.php (consulta dues taules unirles per categoria) */ public function index() { $blog_posts = blog_posts::select( "blog_posts.title", "blog_posts.banner", "blog_posts.excerpt", "blog_posts.published_at", "blog_categories.name as name" ) ->join("blog_categories", "blog_categories.id", "=", "blog_posts.blog_category_id") ->get(); return view('gallery_posts', compact('blog_posts')); }
2/** routes/web.php */ Route::get('/gallery_posts','App\Http\Controllers\BlogPostsController@index');
3/**resources\views\gallery_posts.blade.php */ @foreach ($blog_posts as $blog_post) @endforeach
No valid image directory found or the category is not valid for the gallery.