1) This is my order table :
Schema::create('orders', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('category_id')->unsigned();
$table->integer('product_id')->unsigned();
$table->integer('variant_id')->unsigned();
$table->integer('quantity');
$table->integer('total');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('category_id')->references('id')->on('categories');
$table->foreign('product_id')->references('id')->on('products');
$table->foreign('variant_id')->references('id')->on('variants');
});
2) This is my Order Blade :
<tbody>
@foreach($orders as $order)
<tr>
<td></td>
<td></td>
<td>/-</td>
</tr>
@endforeach
</tbody>
3) This is my OrderController :
public function index()
{
$orders = Order::where('user_id', auth()->user()->id)->get();
return view('orders', compact('orders', 'variants'));
}
Now I want to print the variant name in my blade file but only thing I can print is id's. I've tried many things but still can't get the precise answer. I know it can be done with foreign keys but how do I use these foreign keys to print variant_name or anything from variant table.
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2GQJ1Pq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire