Search
 
SCRIPT & CODE EXAMPLE
 

PHP

automatically make created_by and updated_by using observer laravel

<?php 

<?php 

namespace AppObservers;

class RecordFingerPrintObserver {

    $userID;

    public function __construct($userID){
        $user = Auth::user();
        $this->userID = $user->getId();
    }

    public function saving($model)
    {
        $model->modfied_by = $this->userID;
    }

    public function saved($model)
    {
        $model->modfied_by = $this->userID;
    }


    public function updating($model)
    {
        $model->modfied_by = $this->userID;
    }

    public function updated($model)
    {
        $model->modfied_by = $this->userID;
    }


    public function creating($model)
    {
        $model->created_by = $this->userID;
    }

    public function created($model)
    {
        $model->created_by = $this->userID;
    }


    public function removing($model)
    {
        $model->purged_by = $this->userID;
    }

    public function removed($model)
    {
        $model->purged_by = $this->userID;
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: remove public from url laravel 7 
Php :: fuelphp authentication 
Php :: laravel project in css 
Php :: Laravel-permission update name 
Php :: php artisan make:auth is not working in laravel 8 
Php :: AWS S3 - accessing and working with JSON files 
Php :: order by array like sql php 
Php :: php accounting ledger 
Php :: $user-id show 0 in blade laravel 8 
Php :: How to add page heading in FPDF PHP 
Php :: Comment supprimer les éléments liés à WordPress oEmbed 
Php :: WordPress Plugin Code Definition 
Php :: php cors error 
Php :: SSL certificate problem: certificate has expired php 
Php :: remove ul container from wp_nav_menu 
Php :: php remove value from array if exists 
Php :: prevent cross site scripting php 
Php :: copy(/Users/admin/Library/Caches/composer/files/fakerphp/faker 
Php :: required if null / require without laravel 
Php :: barryvdh laravel dompdf pages total 
Php :: Display a variable containing html in laravel 
Php :: wordpress get_permalink not working 
Php :: laravel eloquent order by relationship 
Php :: laravel seeder with relationship 
Php :: WordPress Creating “startupl” folder and Wrtting to .htaccess 
Php :: loop IlluminateSupportCollection Object ( [items:protected] = 
Php :: function() use() php clousure examples 
Php :: contact form dropdown from post 
Php :: Best Performance monitoring tools for php 
Php :: wordpress not logging when using ngrok 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =