Undefined property: IlluminateDatabaseQueryBuilder::$title
public function show(string $id) {
$books = DB::table("book_tbls")
->where("author_tbls.id", "=", $id)
->where("author_tbls.id", "=", "book_tbls . author_id")
->where("categories.id", "=", $id)
->where("categories.id", "=", "book_tbls . category_id");
// $books = book_tbl::find($id);
return view('books.show', compact('books'));
}
I am learning laravel for 3 months, Now I am writing library system. In show function, I will show the details of the books eg. author name, book title and category but when I join those tables the properties are not shown. Please help.
2
Answers
joins are missing. here i am adding the joins
public function show(string $id) {
$books = DB::table("book_tbls")
List item
// $books = book_tbl::find($id);
return view(‘books.show’, compact(‘books’));
}
Here I assume in book_tbl we have column name author_id. author_id column referencing to author id exists in author_tbl. same for the categories
Try this
}