Support the ongoing development of Laravel.io →
Authentication Session
Last updated 2 years ago.
0

Hi cuemur,

To test your code I create one table like:

CREATE TABLE `inventory` (
  `ID` INT NOT NULL,
  `pName` VARCHAR(45) NULL);


INSERT INTO inventory VALUES(1,'test');

To match with your example:

@if($prop) You own {{ $prop->pName }} @else

You have to get only one element, to display the pName. To do that use first:

$prop = DB::table('Inventory')->where('ID', 1)->first();

And after you can check it with your code

@if($prop) You own {{ $prop->pName }} @else You do not own any properties @endif

If you want check more than one result you have to change your template

$prop = DB::table('Inventory')->where('ID', 1)->get();
@if($prop) 
You owns:
@foreach($prop as $p)
 {{ $p->pName }} 
@endforeach
@else 
You do not own any properties 
@endif
0

Sign in to participate in this thread!

Eventy

Your banner here too?

cuemur cuemur Joined 7 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.