mardi 23 janvier 2018

Laravel - Access The Authenticated User In A Model Observer

I followed the documentation for creating a model observer here https://laravel.com/docs/5.5/eloquent#observers.

But when I try and access the authenticated user I get null.

How can I access the authenticated user in the model observer?

<?php

namespace App\Observers;

use App\Customer;

class CustomerObserver
{
    public function created(Customer $customer)
    {
        dd(auth()->user());
    }

    public function updated(Customer $customer)
    {
        dd(auth()->user());
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire