Property [categories] does not exist on this collection instance. (View: D:\xampp\htdocs\olshop\resources\views\backend\product\index.blade.php)

this is my Model

//relation from model products to model categorys
public function categorys()
{
return $this->belongsTo('App\Category');
}

//relation from model products to model categorys
public function categorys()
{
return $this->belongsTo('App\Category');
}

this is my controller

 public function index()
{
//controller buat manggil foreachnya
$data['title'] ='Product';
$data['page'] = 'Semua Product';
$data['products'] = Product::all();
return view('backend.product.index', $data);
}

**this is my **

                @foreach($products->categorys as $key => $value)
<tr>
<!-- view bladenya -->
<td></td>
<td></td>
<td></td>

I am trying to using $products->$categorys but its gone wrong



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Y3w3Vy
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time