Maybe of course I read the documentation incorrectly, but many-to-many links work with find() , but if I need to post the entire value for which id_user is equal to the authorized user. That is where my problem came out. Is it possible for me to shorten the code?
$directions = Direction::where('id_user', Auth::user()->id)->with('executes'); $execute = []; foreach ($directions->get() as $value){ foreach (Direction::find($value->id)->executes()->get() as $item){ $execute[] = $item->name; } } dd($execute); Tried such value $roles = Direction::find(1)->executes(); Only minus I need all the values that fall under the condition id_user = Auth::user()->id in the Direction model. I did not understand the hasManyThrough account, whether or not the table is right for me, I have the following Direction
id name id_user Execute
id name id_user Execute_direction
direction_id execute_id
id_userdo not store in the tableExecute_direction? - Vanya Avchyan