jeudi 17 mars 2016

Using ::find but with a custom where clause

I use ::find to find the business but business_position I need to use WHERE business_id = and WHERE id to find the correct position, and example is avalible below...

<?php
    $s = Stats::find(Auth::user()->id);
    $myJob = \App\Businesses::find($s->business_id);

    $matchedValues = ['business_id' => $s->business_id, 'id' => $s->business_position];
    $myPosition = \App\BusinessPositions::where($matchedValues)->get();
    ?>

And using $myPosition I use

{{ $myPosition->pay_amount }}

And on that line it throws and error...

Undefined property: Illuminate\Database\Eloquent\Collection::$pay_amount (View: C:\Users\Darren\MyLavProject\resources\views\pages\business\business.blade.php)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire