1. Go to this page and download the library: Download uzapoint/auditable 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/ */
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Uzapoint\Auditable\Traits\Auditable;
class Order extends Model
{
use Auditable;
use SoftDeletes;
protected $fillable = [
'customer_id',
'status',
'total',
'void_reason',
'rejection_reason',
];
}
use Uzapoint\Auditable\Facades\Audit;
Audit::log('invoice.sent', 'Invoice #123 was sent to the customer', [
'log_name' => 'invoices',
'subject_type' => App\Models\Invoice::class,
'subject_id' => 123,
'causer_id' => auth('api')->id(),
'causer_type' => App\Models\User::class,
'causer_name' => optional(auth('api')->user())->name,
'causer_email' => optional(auth('api')->user())->email,
'changes' => null,
'properties' => [
'channel' => 'email',
],
]);