vendredi 24 avril 2020

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

Aucun commentaire:

Enregistrer un commentaire