I want to join two tables yet it will only return the not nulled foreign key column
it will all only show if i use 1 as default value to all and put nothing inside the foreign id 1 row to look like its empty but the problem there is if i update one row that has default 1 value it will update all foreign id with 1 value and i don't want that to happen.
$unit = DB::table('franchises')
->join('units', 'franchises.id', '=', 'units.franchise_id')
->orderBy('units.created_at', 'desc')->paginate(20);
return view('register-unit', compact('unit'));
i have this migration query
$table->integer('franchise_id')->unsigned()->default(null);
$table->foreign('franchise_id')->references('id')->on('franchises')->onDelete('cascade')->onUpdate('cascade');
i want it to make the all foreign key null as a default and still can return all using join. How can i attain it?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire