Последняя версия с сервера прошлого разработчика
This commit is contained in:
45
app/Domain/Comments/Models/Comment.php
Executable file
45
app/Domain/Comments/Models/Comment.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace App\Domain\Comments\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Model;
|
||||
use App\Domain\Feeds\Models\Feed;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Domain\Complaints\Models\CommentComplaint;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
public function feed()
|
||||
{
|
||||
return $this->belongsTo(Feed::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function answer_to()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'to_user_id');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Comment::class, 'parent_id');
|
||||
}
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'parent_id');
|
||||
}
|
||||
|
||||
|
||||
public function complaints()
|
||||
{
|
||||
return $this->hasMany(CommentComplaint::class);
|
||||
}
|
||||
|
||||
}
|
||||
20
app/Domain/Comments/Observers/NovaCommentObserver.php
Executable file
20
app/Domain/Comments/Observers/NovaCommentObserver.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Comments\Observers;
|
||||
|
||||
use App\Domain\Comments\Models\Comment;
|
||||
|
||||
class NovaCommentObserver
|
||||
{
|
||||
public function deleting(Comment $comment)
|
||||
{
|
||||
if(!$comment->trashed()){
|
||||
$complaints = $comment->complaints;
|
||||
foreach ($complaints as $complaint) {
|
||||
$complaint->status = 'reviewed_bad';
|
||||
$complaint->moderator_checking_id = auth()->id();
|
||||
$complaint->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user