dimanche 12 janvier 2020

how to find out the value in the EAV table is filled or not

I have a problem here, I use a database with the EAV (Entity Artibute Value) model, here I get data by way of, where user_id = $ id -> get (), and on the blade I want to create a condition if only one the data in $ user has a value in the description column so he will bring up a button from the description that has the contents this my sampel table

_______________________________________
|id|user_id|name    |description       |
|1| 2      |micahel |                  |
|2| 2      |micahel |                  |
|3| 2      |micahel |                  |
|4| 2      |micahel |www.google.com    |
|5| 3      |jackson |                  |
|6| 3      |jackson |                  |
|7| 3      |jackson |                  |


$table = DB::table(description)->where(user_id,$id)->get();

so my expectation is, if there is only one data that I take with where has a value in the value column, it will bring up the href button, i try with

@if($table->description!=0)
<a href="">go to description</a>
@else
This user has no description
@endif

i try that but it's doesn't work

Property [description] does not exist on this collection instance


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire