Skip to content
Advertisement

How to use pluck to get specific data from other table in Laravel?

From SalesController, I want to get specific name from table Item and passed to HTML.

My controller looks like

JavaScript

My HTML is

JavaScript

But I get the following error after trying to access the page:

Trying to get property ‘name’ of non-object (View: C:xampphtdocsinventoryAppresourcesviewsSaleindex.blade.php)

Advertisement

Answer

there are two way

1.Using relationship

JavaScript

so you can use like below

JavaScript

2. Using array data

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement