Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ngozistephen's avatar

Date Range Picker

I trying to send a request to my database is given me this error mssage Integrity constraint violation: 1048 Column 'end_date' cannot be null (SQL: insert into porfolios (job_title, project_name, user_id, content, end_date, start_date, featured_img, published_at, updated_at, created_at)

look at my code public function store(StorePorfolioRequest $request){

    $porfolio = new Porfolio;

    $porfolio->job_title = $request->job_title;
    $porfolio->project_name = $request->project_name;
    $porfolio->user_id = Auth::user()->id;
    $porfolio->content = $request->content;
    $porfolio->end_date = $request->end_date;
    $porfolio->start_date = $request->start_date;
    $porfolio->featured_img = $this->upload_image($request);
    $porfolio->published_at = $request->filled('published') ? Carbon::now() : null;    
    $porfolio->save();

    return response()->json('ok', 201);    
}
0 likes
3 replies
sr57's avatar

Use a migration to change make your column nullable, or define a default date (in the db or in your strore function)

Ngozistephen's avatar

@sr57 this is my migration public function up() { Schema::table('porfolios', function (Blueprint $table) { $table->renameColumn('dates', 'end_date'); $table->date('start_date')->default(now())->after('dates'); }); }

Please or to participate in this conversation.