我正在尝试打印与我的餐厅相关的菜肴。每道菜都分配了一个restaurant_id。
每个餐厅都分配了一个ID.
餐厅迁移
Schema::create('restaurants', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->timestamps();
});
盘迁移
Schema::create('dishes', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->float('price');
$table->integer('restaurant_id');
$table->string('image');
$table->timestamps();
});
餐厅播种机
DB::table('restaurants')->insert([
'name' => 'Bellos Pizzeria',
'updated_at' => DB::raw('CURRENT_TIMESTAMP'),
]);
DB::table('restaurants')->insert([
'name' => 'McDonalds',
'updated_at' => DB::raw('CURRENT_TIMESTAMP'),
]);
DB::table('restaurants')->insert([
'name' => 'Ericos',
'updated_at' => DB::raw('CURRENT_TIMESTAMP'),
]);
播种机
DB::table('dishes')->insert([
'name' => 'Butter Chicken',
'price' => '12',
'restaurant_id' => 1,
'image' => 'dishes_images/default.png',
'updated_at' => DB::raw('CURRENT_TIMESTAMP'),
]);
DB::table('dishes')->insert([
'name' => 'Hamburger',
'price' => '10',
'restaurant_id' => 2,
'image' => 'dishes_images/default.png',
'updated_at' => DB::raw('CURRENT_TIMESTAMP'),
]);
个别餐厅视图上的 html
@section('content')
<h1> {{$restaurant->name}} </h1>
<a href="/assignment2/public/restaurant"> back </a>
@endsection
我正在尝试打印与餐厅相关的菜肴。例如,id=1将在餐厅“Bellos Pizzeria”( ) 中列出的“Butter Chicken” ( id=1)。
慕容3067478
莫回无