PHP code example of orisintel / laravel-model-auditlog
1. Go to this page and download the library: Download orisintel/laravel-model-auditlog 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/ */
orisintel / laravel-model-auditlog example snippets
public function getAuditLogIgnoredFields() : array
{
return ['posted_at'];
}
public function getAuditLogIgnoredFields() : array
{
if ($this->postHasBeenPublished()) {
return ['title'];
}
return [];
}
class PostTag extends Pivot
{
use AuditLoggablePivot;
/**
* The array keys are the composite key in the audit log
* table while the pivot table columns are the values.
*
* @var array
*/
protected $audit_loggable_keys = [
'post_id' => 'post_id',
'tag_id' => 'tag_id',
];
}
composer
use Fico7489\Laravel\Pivot\Traits\PivotEventTrait;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use PivotEventTrait;
public function tags()
{
return $this->belongsToMany(Tag::class)
->using(PostTag::class);
}
public function posts()
{
return $this->belongsToMany(Post::class)
->using(PostTag::class);
}
composer
use Awobaz\Compoships\Compoships;
use OrisIntel\AuditLog\Models\BaseModel;
class PostTagAuditLog extends BaseModel
{
use Compoships;