Skip to content

Instantly share code, notes, and snippets.

@cpereiraweb
Created June 20, 2017 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpereiraweb/55940526daa6e33706cd86efa4afc835 to your computer and use it in GitHub Desktop.
Save cpereiraweb/55940526daa6e33706cd86efa4afc835 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: claudio
* Date: 01/11/16
* Time: 22:40
*/
namespace SnPortal\Observers;
use SnPortal\Models\Client;
class ClientObserver
{
/**
* Listen to the Client creating event.
*
* @param Client $client
* @return void
*/
public function creating(Client $client)
{
$client->created_by = (App::runningInConsole()?1:\Auth::user()->id); // Se estiver rodando via artisan, atribui 1
$client->updated_by = (App::runningInConsole()?1:\Auth::user()->id); // Se estiver rodando via artisan, atribui 1
}
/**
* Listen to the Client updating event.
*
* @param Client $client
* @return void
*/
public function updating(Client $client)
{
dd(\Auth::user());
$client->updated_by = (App::runningInConsole()?1:\Auth::user()->id); // Se estiver rodando via artisan, atribui 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment