Jimnoel Valmonte
Jimnoel Valmonte

Reputation: 1

Adding another table named posts that contains the user_id of Sentinel Cartalyst

I am using Sentinel for authentication for my grading system project with added features like social networking system and advance authentication system, my problem is:

$post = new Post;

$post->title=$request->title; 
$post->body=$request->body; 
$post->user_id = auth()->user()->id; //need to convert into a cartalyst way
$post->save();

I want the id of the user table to be saved on the user_id of the posts table.

Upvotes: 0

Views: 45

Answers (1)

Vicky Gill
Vicky Gill

Reputation: 734

Make a relation in Model then Use attach() function for attaching user to post for more info check Laravel Docs [https://laravel.com/docs/5.5/eloquent-relationships]

Upvotes: 0

Related Questions