Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

fillable in laravel

//for comment Section

//commentController.php
    public function store(StoreCommentRequest $request)
    {
        //
        $comment = Comment::create([
            "message"=>$request->message,
            "post_id"=>$request->post_id,
            "user_id"=>Auth::id(),
        ]);
        return redirect()->to(url()->previous()."#comment-create");    
    }

//Comment.php <= model

    class Comment extends Model
    {
    use HasFactory;

    protected $fillable =["message","user_id","post_id"];
    }

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #fillable #laravel
ADD COMMENT
Topic
Name
5+3 =