e.g. a category that can have a parent_id which is another category
$theContract = DB::table('contract_tb')->leftJoin('book_tb', 'contract_tb.book_id', '=', 'book_tb.book_id')
->where('contract_tb.book_id','=',$theBooks[0]->book_id)
->where(function ($query) {