Я пытаюсь отобразить страницу участника, но получаю ошибку.
Use of undefined constant members - assumed 'members' (this will throw an Error in a future version of PHP) (View: C:\laragon\www\eshop\resources\views\components\members.blade.php)
members.blade. php в папке компонентов
@foreach ($members as $member)
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Mon profil</h5>
<p class="card-text">{{$member->firstname}}</p>
<p class="card-text">{{$member->lastname}}</p>
<p class="card-text">{{$member->balance}}</p>
<a href="{{ route(members.edit, ['members' => $member->id]) }}" class="btn btn-primary"
role="button">Afficher
plus...</a>
</div>
</div>
@endforeach
MemberController. php
public function index()
{
$members = DB::table('members')->get();
// $members = Member::all();
return view('members.index', ['members' => $members, 'mode' => 'member']);
}
index.blade. php в папке для членов
@extends('members.template')
@section('title', 'Accueil')
@section('content')
@component('components.members', ['members' => $members, 'mode' => 'member'])
@endcomponent
@endsection
миграции
public function up()
{
Schema::create('members', function (Blueprint $table) {
$table->id();
$table->string('firstname');
$table->string('lastname');
$table->string('birth');
$table->string('email');
$table->string('balance');
$table->timestamps();
});
}
Спасибо за вашу помощь