You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Engelsystem\Models;
|
|
|
|
use Engelsystem\Models\User\User;
|
|
use Engelsystem\Models\User\UsesUserModel;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* This class represents a message send trough the system.
|
|
*
|
|
* @property integer $id
|
|
* @property integer $receiver_id
|
|
* @property boolean $read
|
|
* @property string $text
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property-read User $receiver
|
|
* @method static Builder|Message whereId($value)
|
|
* @method static Builder|Message whereReceiverId($value)
|
|
* @method static Builder|Message whereRead($value)
|
|
* @method static Builder|Message whereText($value)
|
|
* @method static Builder|Message whereCreatedAt($value)
|
|
* @method static Builder|Message whereUpdatedAt($value)
|
|
*/
|
|
class Message extends BaseModel
|
|
{
|
|
use UsesUserModel;
|
|
|
|
/** @var bool enable timestamps */
|
|
public $timestamps = true;
|
|
|
|
/** @var string[] */
|
|
protected $casts = [
|
|
'user_id' => 'integer',
|
|
'receiver_id' => 'integer',
|
|
'read' => 'boolean',
|
|
];
|
|
|
|
/** @var string[] */
|
|
protected $fillable = [
|
|
'user_id',
|
|
'receiver_id',
|
|
'read',
|
|
'text',
|
|
];
|
|
|
|
/** @var array */
|
|
protected $attributes = [
|
|
'read' => false,
|
|
];
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function receiver(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'receiver_id');
|
|
}
|
|
}
|