for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Xetaravel\Models;
use Eloquence\Behaviours\CountCache\Countable;
use Illuminate\Support\Facades\Auth;
class DiscussUser extends Model
{
use Countable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_id',
'conversation_id'
];
* The "booting" method of the model.
* @return void
protected static function boot()
parent::boot();
// Set the user id to the new user before saving it.
static::creating(function ($model) {
$model->user_id = Auth::id();
});
}
* Return the count cache configuration.
* @return array
public function countCaches(): array
return [
'user_count' => [DiscussConversation::class, 'conversation_id', 'id']
* Get the user that owns the user.
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
public function user()
return $this->belongsTo(User::class);
* Get the conversation that owns the user.
public function conversation()
return $this->belongsTo(DiscussConversation::class);