完整性约束违规:1048列

enter image description here

enter image description here

Hello I have an error in my database. the user registers in the users table and now he has to post an ad. I'm trying to get his id in the ads table. But it returns me this error:

SQLSTATE [23000]: Integrity constraint violation: 1048 Column 'user_id' can not be null (SQL: insert intoads (user_id,services, head,level_study, language,experience, localization,description, contact,updated_at, created_at) values ​​(?, Household, Housekeeper, BAC + 2, a little, 2years, Yopougon, pnjjjk , 09789070, 2019-06-05 08:31:38, 2019-06-05 08:31:38))

public function store(Adstore $request)
{
    $validated = $request->validated();
    $user_id = Auth::user()['id'];
    $ad = new Ad();
    $ad->user_id = $user_id;
    $ad->services = $validated['dropdown_service'];
    $ad->titre = $validated['title'];
    $ad->niveau_etude = $validated['dropdown_etude'];
    $ad->langue = $validated['langue'];
    $ad->experience = $validated ['experience'];
    $ad->localisation = $validated ['local'];
    $ad->description = $validated ['description'];
    $ad->contact = $validated ['contact'];
    $ad->save();
    return redirect()->route('accueil')->with('success','Votre annonce a été postée.');
}

Make some changes in code as per below:

In controller:

public function store(Adstore $request)
{
    $validated = $request->validated();

    $user_id = Auth::user()->id;

    $ad = Ad::create([
        'user_id' => $user_id,        
        'services' => $validated['dropdown_service'],        
        'titre' => $validated['title'],        
        'niveau_etude' => $validated['dropdown_etude'],        
        'langue' => $validated['langue'],        
        'experience' => $validated['experience'],        
        'localisation' => $validated['local'],        
        'description' => $validated['description'],        
        'contact' => $validated['contact'],        
    ]);

    if($ad){
        return redirect()->route('accueil')->with('success','Votre annonce a été postée.');
    } else {
        return redirect()->route('accueil')->with('error','Something went wrong.');
    }    
}

You have to access auth user id like this $user_id = Auth::user()->id;

Instead of "$user_id = Auth::user()['id'];" use this : "$user_id = Auth::user()->id;" it will work.