Hi, i am trying to post a form to my laravel backend but I keep getting a 500 internal server error. Im using a vue frontend with axios to send the post request.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Engagement extends Model
{
public function client()
{
return $this->belongsTo('App\Client');
}
public function engagement_tasks()
{
return $this->belongsToMany('App\Task');
}
}
I believe my issue is coming from the 'client_id' that is being added for the belongsTo() relationship it has with the parent model Client.
Currently my relationships are
User has many Tasks
Task belongs to User
Client has many Engagements
Engagement belongs to Client
Engagement and Tasks have a many to many relationship
So I understand that when I submit data belonging to a user like this
'user_id' => auth()->user()->id,
on the store method it will reference the user model but for some reason that does not work for the client like this
'client_id' => client()->id,
I believe i am missing a step that is telling laravel which client the new engagement belongs to but Im not sure what that step is..
API post to store method return 500 internal server error
Hi, i am trying to post a form to my laravel backend but I keep getting a 500 internal server error. Im using a vue frontend with axios to send the post request.
here is my route
here is the EngagementsController for the store method
and this is the Engagement model it references
I believe my issue is coming from the 'client_id' that is being added for the belongsTo() relationship it has with the parent model Client.
Currently my relationships are
So I understand that when I submit data belonging to a user like this
on the store method it will reference the user model but for some reason that does not work for the client like this
I believe i am missing a step that is telling laravel which client the new engagement belongs to but Im not sure what that step is..
Any help would be greatly appreciated!!!