Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

You are fetching the same data twice by using the find() in both lines. You could just use the query you have for $campaignStatus. That query would return a Collection object with both the variables you are passing to your view.

Or try using the one query:

$campaign = Campaign::find($id)->campaignStatus;
Last updated 1 year ago.
0

Using

 $campaign = Campaign::find($id);

will populate the $campaign with model data, Since id is already set, now you can get the comaign status like ( another find call was not needed ):

$status = $campaign->campaignStatus;
//or 
$status = $campaign->campaignStatus()->first();

this will return the related stutus for the campaign.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jasondavis jasondavis Joined 19 Feb 2014

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.