laravel-learn-bbs/app/Observers/ReplyObserver.php

26 lines
508 B
PHP
Raw Normal View History

2018-01-15 15:24:11 +00:00
<?php
namespace App\Observers;
use App\Models\Reply;
// creating, created, updating, updated, saving,
// saved, deleting, deleted, restoring, restored
class ReplyObserver
{
public function creating(Reply $reply)
{
2018-01-15 15:59:30 +00:00
$reply->setAttribute('content', clean($reply->getAttribute('content'), 'user_topic_body'));
2018-01-15 15:24:11 +00:00
}
public function updating(Reply $reply)
{
//
}
2018-01-15 15:59:30 +00:00
public function created(Reply $reply)
{
$reply->topic->increment('reply_count', 1);
}
2018-01-15 15:24:11 +00:00
}