How to create projects method with belongstomany relationship in user model

Updated at 22-Jul-2021, By samar

How to create projects method with belongstomany relationship in user model

With this article, we will examine several different instances of how to solve the "How to create projects method with belongstomany relationship in user model".

You can create the projects method with belongstomany relationship in user model. You have to also create a project_user pivot table to get the data from the pivot table.
  • Create belongs to many relationship with projects method in user model

    --PATH App\Models\User.php
    public function projects(){
            return $this->belongsToMany('App\Models\Project')
                        ->withPivot('is_manager', 'order_by')
                        ->withTimestamps();
        }
    

Back to code snippet queries related laravel