fixed the created_at issue from the policy caused by the setStartPost setting created_at to null

This commit is contained in:
Daniel Klabbers 2018-05-14 11:52:01 +02:00
parent 80cc03e4f1
commit 32c7f1ee5d
2 changed files with 15 additions and 6 deletions

View File

@ -30,10 +30,18 @@ class StartDiscussion
public $data;
/**
* @param User $actor The user authoring the discussion.
* @param array $data The discussion attributes.
* The current ip address of the actor.
*
* @var string
*/
public function __construct(User $actor, array $data, $ipAddress)
public $ipAddress;
/**
* @param User $actor The user authoring the discussion.
* @param array $data The discussion attributes.
* @param string $ipAddress The current ip address of the actor.
*/
public function __construct(User $actor, array $data, string $ipAddress)
{
$this->actor = $actor;
$this->data = $data;

View File

@ -11,6 +11,7 @@
namespace Flarum\Discussion;
use Carbon\Carbon;
use Flarum\Database\AbstractModel;
use Flarum\Database\ScopeVisibilityTrait;
use Flarum\Discussion\Event\Deleted;
@ -138,7 +139,7 @@ class Discussion extends AbstractModel
$discussion = new static;
$discussion->title = $title;
$discussion->created_at = time();
$discussion->created_at = Carbon::now();
$discussion->user_id = $user->id;
$discussion->setRelation('startUser', $user);
@ -209,7 +210,7 @@ class Discussion extends AbstractModel
*/
public function setStartPost(Post $post)
{
$this->created_at = $post->time;
$this->created_at = $post->created_at;
$this->user_id = $post->user_id;
$this->first_post_id = $post->id;
@ -224,7 +225,7 @@ class Discussion extends AbstractModel
*/
public function setLastPost(Post $post)
{
$this->last_posted_at = $post->time;
$this->last_posted_at = $post->created_at;
$this->last_posted_user_id = $post->user_id;
$this->last_post_id = $post->id;
$this->last_post_number = $post->number;