PHP code example of umairhanifdev / laravel-table-logger

1. Go to this page and download the library: Download umairhanifdev/laravel-table-logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

umairhanifdev / laravel-table-logger example snippets



use UmairHanif\LaravelTableLogger\Traits\Loggable;

use UmairHanif\LaravelTableLogger\Traits\HasLogs;

  

class  ExaminationReport  extends  Model

{

use  Loggable, HasLogs;

}



$report = ExaminationReport::find($id);

$reportLogs = $report->logs()->get();



$examReports = ExaminationReport::where('user_id', 16)->get();

$examinationLogs = $examReports->logsBatch()

->where('this_log_action', 'update') // optional filter

->get();



use UmairHanif\LaravelTableLogger\Helpers\LoggerLog;

  

LoggerLog::logAction('examination_reports', $id, 'delete');

DB::table('examination_reports')->where('id', $id)->delete();



$user = User::with(['examination' => function ($q) {

$q->whereStatus(1)->orderBy('id', 'DESC');

}])->find($id);

  

// Logs for the parent model (User)

$usersLogs = $user->logs()->get();

  

// Logs for nested model (Examinations)

$examinationLogs = collect();

if ($user->examination) {

$examinationLogs = $user->examination->logsBatch()

->where('this_log_action', 'update') //optional - to filter the logs futher

->get();

}



'irregular_plurals' => [

'people' => 'person',

'children' => 'child',

'men' => 'man',

'women' => 'woman',

],

bash

php  artisan  vendor:publish  --tag=config