You've already forked Atomcms-edit
Initial commit
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Articles;
|
||||
|
||||
use App\Models\Concerns\BelongsToUser;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $article_id
|
||||
* @property int $user_id
|
||||
* @property string $comment
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read WebsiteArticle|null $article
|
||||
* @property-read User|null $user
|
||||
*/
|
||||
class WebsiteArticleComment extends Model
|
||||
{
|
||||
use BelongsToUser;
|
||||
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
public function article(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WebsiteArticle::class, 'article_id');
|
||||
}
|
||||
|
||||
public function canBeDeleted(): bool
|
||||
{
|
||||
return $this->user_id === Auth::id() || hasPermission('delete_article_comments');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user