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.
pixelfed/app/Models/DirectMessage.php

36 lines
782 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Auth;
class DirectMessage extends Model
{
public function status(): BelongsTo
{
return $this->belongsTo(Status::class, 'status_id', 'id');
}
public function url(): string
{
return config('app.url').'/account/direct/m/'.$this->status_id;
}
public function author(): BelongsTo
{
return $this->belongsTo(Profile::class, 'from_id', 'id');
}
public function recipient(): BelongsTo
{
return $this->belongsTo(Profile::class, 'to_id', 'id');
}
public function me(): bool
{
return Auth::user()->profile->id === $this->from_id;
}
}