// вот таблица поставок
Schema::create('deliveries', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('product_id');
$table->unsignedInteger('qty');
$table->string('person_name');
$table->string('designation');
$table->string('Office');
$table->string('mobile');
$table->date('date');
$table->timestamps();
});
// здесь таблица продуктов
Schema::create('products', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('category_id');
$table->unsignedInteger('item_id');
$table->unsignedInteger('brand_id');
$table->string('item_model')->nullable();
$table->unsignedInteger('qty');
$table->unsignedInteger('item_price');
$table->unsignedInteger('total_price');
$table->timestamps();
});
// здесь таблица товаров
Schema::create('items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedInteger('category_id');
$table->string('item_name')->unique();;
});
как получить данные таблицы товаров и изделий из таблицы поставок по красноречивой модели? У меня есть 3 файла модели: Delivery. php, Item. php и Product. php Я хочу получить доступ к DeliveryController. php индексным методом. Но я не могу получить доступ к item_name
public function index()
{
return Delivery::with('user')
->with('product')
->orderby('id', 'desc')->get();
}
<tr role="row" class="odd" v-for="(delivery, index) in deliveries" :key="index">
<td>{{ index+1 }}</td>
<td>{{ delivery.product.item_name}}</td>
</tr>