How can I replace existing relation? At this moment, I have tables:
requirements
user_requirement
And I have this relation in User model:
public function requirements(){
return $this->belongsToMany('\App\Requirement', 'user_requirement')->withTimestamps();
}
Now I created new table - activities:
And now, how can I set ID from activities for requirement_id in this relation in model? I do somethink like this:
return $this->belongsToMany('\App\Activities', 'user_requirement', 'requirement_id', 'ID' )->withTimestamps();
But when I'm try to do in view ($req->ID is Activity ID):
@if( !$user->activities()->get()->contains( $req->ID ) ) {
No activity
@else
Yes activity
@endif
I'm getting always FALSE
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community