I am new to Laravel and web development.
I have two models User and Activity. I want to write a function for User to join an Activity. But I am not sure where to write or should I store in database?
class Activity extends Model
{
    protected $primaryKey = 'act_id';
    public function owner() {
        return $this->hasOne('App\User', 'user_id')->where('owner', true);
    }
    public function user() {
        return $this->belongsToMany('App\User', 'user_id');
    }
    //Not sure if this works?
    public function joinAct($users){
        return $this->users()->attach($users);
    }
}
And the User:
class User extends Model
{
    protected $primaryKey = 'user_id';
    public function activities(){
        return $this->belongsToMany('App\Activity');
    }
}
So where should I write the function join_activity, in Activity model or somewhere else? And I wonder if there is a quick way to test like using php artisan tinker? Thank you!
