for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Xetaravel\Models;
use Illuminate\Support\Facades\Auth;
use Xetaravel\Models\Presenters\DiscussLogPresenter;
class DiscussLog extends Model
{
use DiscussLogPresenter;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_id',
'loggable_id',
'loggable_type',
'event_type',
'data'
];
* The attributes that should be cast to native types.
protected $casts = [
'data' => 'array'
* The "booting" method of the model.
* @return void
protected static function boot()
parent::boot();
// Set the user id to the new post before saving it.
static::creating(function ($model) {
$model->user_id = Auth::id();
});
}
* Get the user that owns the log.
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user()
return $this->belongsTo(User::class);
* Get the loggable relation.
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
public function loggable()
return $this->morphTo();