I'm working on a project Laravel 5, which requires that each model had tracking user attributes ( created_by, updated_by, deleted_byetc.).
I can easily identify the current user with Auth::guest()and Auth::user().
I want these attributes to be the default for a particular user (e.g. sysadmin) if called from artisan tinker.
The problem is twofold:
Auth::guest() cannot distinguish between master-masters and actual guest in a web application.- I do not have to call directly
MyModel::create()to be able to transmit special instructions. It can be called from another class or namespace.
The only solutions I can think of are as follows:
- Somehow determine if a call is made from
artisan tinkeror - Be able or require a user to log in
artisan tinker
Is it possible?
source
share