A user(employer) have many posts and many user(employee) can apply these posts . Point is employer should get which users applied for each its posts.
I tried $employees = Post::find(//anyNumber//)->people;
it gives proper applicants infos but it should be dynamic for each employer user .
Tables..
applies -> | users_id(employee) | posts_id |
posts -> | id | user_id(employer) | (other posts cols ... )
user_info -> | id | (name col etc... for employee)
Post Model..
public function people()
{
return $this->belongsToMany(Info::class , 'applies', 'user_id' , 'posts_id');
}
Controller..
public function index()
{
$user_id = Auth::id();
$myPosts = Post::where('user_id',$user_id)->get();
$employees = Post::find(//anyNumber//)->people; // this line
dd($employees);
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3lX9bSK
via IFTTT
Aucun commentaire:
Enregistrer un commentaire