В моем контроллере есть мой метод:
Код: Выделить всё
public function show(string $id)
{
$technology = Technology::findOrFail($id);
return view('home.technology.show', compact('technology'));
}
Код: Выделить всё
@if($technology->exercises->isEmpty())
Aucun exercice disponible pour cette technologie.
@else
[list]
@foreach ($technology->exercises as $exercise)
[*]
[url={{ route(]id) }}">{{ $exercise->name }}[/url]
@endforeach
[/list]
@endif
Код: Выделить всё
Route::resource('/technology',TechnologyController::class);
Код: Выделить всё
class Technology extends Model
{
use HasFactory;
protected $hidden = ['created_at','updated_at'];
public function exercises()
{
return $this->belongsToMany(Exercise::class, 'exercise_technologies');
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... in-laravel
Мобильная версия