How to put a field in other table?

Posted 4 months ago by irankhosravi

Look at my codes.

RequisitionController.php

$requisitions = Requisition::with('schools')->where('city_id', auth()->user()->city_id)->latest()->paginate(25);

Requisition.php

public function schools ()
{
    return $this->belongsTo(SchoolsList::class, 'school_id');
}

I have two tables schools and requisitions in my project.

schools table

id, province_id, city_id, gender,......

requisitions table

id, school_id, type, ...

How to put schools in RequisitionController

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.