Hi Omar,
I have been messing with a job board database Im porting over. I have opportunities with Client, Specialty, and Status fks. I think this works:
class OpportunitiesController extends Controller {
public function index() {
$opportunities=Opportunity::with('client','specialty','jobStatus')->take(25)->paginate(15);
return compact('opportunities');
}
class Opportunity extends Model
{
protected $table = 'opportunities';
protected $primaryKey = 'id';
public function client(){
return $this->belongsTo('App\Client');
}
public function specialty() {
return $this->belongsTo('App\Specialty');
}
public function jobStatus()
{
return $this->belongsTo('App\JobStatus');
}
I am now stuck with a different version of this problem! :-)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community