Question : laravel how to query belongsTo relationship
Answered by : fragile-flatworm-0c0no1b5zwnz
$movies = Movie::whereHas('director', function($q) { $q->where('name', 'great');
})->get();
Source : https://stackoverflow.com/questions/23970762/eloquent-where-condition-based-on-a-belongs-to-relationship | Last Update : Mon, 19 Oct 20
Question : belongs to many laravel
Answered by : brainy-beetle-xps8yb0v5p9r
use App\Models\User;
$user = User::find(1);
$user->roles()->attach($roleId);
Source : https://laravel.com/docs/8.x/eloquent-relationships#updating-many-to-many-relationships | Last Update : Sat, 20 Feb 21
Question : laravel belongsto many create
Answered by : adams-paul
/** * Insert the signature * * @param Request $request * @return ... */ public function store( Request $request ) { // your validation $signature->users()->attach( $request->input('user_id') ); // return
}
Source : https://stackoverflow.com/questions/30704908/laravel-saving-a-belongstomany-relationship | Last Update : Sat, 13 Aug 22
Question : laravel belongsto many create
Answered by : adams-paul
/** * Update the signature with the particular id * * @param $id * @param Request $request * @return ... */ public function update( $id, Request $request ) { // your validation $signature->users()->sync( $request->input('user_id') ); // return
}
Source : https://stackoverflow.com/questions/30704908/laravel-saving-a-belongstomany-relationship | Last Update : Sat, 13 Aug 22