I want to save a new signature in my table signature. Each signature can be linked to multiples users. I have a many to many table between Users and Signatures.
My Model Signature is :
class Signature extends Model {
public $fillable = ['name', 'template'];
public function users() {
return $this->belongsToMany('App\User');
}
}
My Controller SigantureController.php is :
public function store(CreateSignaturesRequest $request)
{
//return $user_id;
$values = $request->only(['name','template']);
Signature::create($values));
return response()->json(['message'=>'SUCCESS'], 201);
}
How can I do to Create my Signature and link it to a user ?
I tried
Signature::create($values)->associate($user_id);
Thanks