mirror of
https://github.com/flarum/framework.git
synced 2024-12-05 00:43:39 +08:00
fixed the created_at issue from the policy caused by the setStartPost setting created_at to null
This commit is contained in:
parent
80cc03e4f1
commit
32c7f1ee5d
|
@ -30,10 +30,18 @@ class StartDiscussion
|
||||||
public $data;
|
public $data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $actor The user authoring the discussion.
|
* The current ip address of the actor.
|
||||||
* @param array $data The discussion attributes.
|
*
|
||||||
|
* @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->actor = $actor;
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
namespace Flarum\Discussion;
|
namespace Flarum\Discussion;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Flarum\Database\AbstractModel;
|
use Flarum\Database\AbstractModel;
|
||||||
use Flarum\Database\ScopeVisibilityTrait;
|
use Flarum\Database\ScopeVisibilityTrait;
|
||||||
use Flarum\Discussion\Event\Deleted;
|
use Flarum\Discussion\Event\Deleted;
|
||||||
|
@ -138,7 +139,7 @@ class Discussion extends AbstractModel
|
||||||
$discussion = new static;
|
$discussion = new static;
|
||||||
|
|
||||||
$discussion->title = $title;
|
$discussion->title = $title;
|
||||||
$discussion->created_at = time();
|
$discussion->created_at = Carbon::now();
|
||||||
$discussion->user_id = $user->id;
|
$discussion->user_id = $user->id;
|
||||||
|
|
||||||
$discussion->setRelation('startUser', $user);
|
$discussion->setRelation('startUser', $user);
|
||||||
|
@ -209,7 +210,7 @@ class Discussion extends AbstractModel
|
||||||
*/
|
*/
|
||||||
public function setStartPost(Post $post)
|
public function setStartPost(Post $post)
|
||||||
{
|
{
|
||||||
$this->created_at = $post->time;
|
$this->created_at = $post->created_at;
|
||||||
$this->user_id = $post->user_id;
|
$this->user_id = $post->user_id;
|
||||||
$this->first_post_id = $post->id;
|
$this->first_post_id = $post->id;
|
||||||
|
|
||||||
|
@ -224,7 +225,7 @@ class Discussion extends AbstractModel
|
||||||
*/
|
*/
|
||||||
public function setLastPost(Post $post)
|
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_posted_user_id = $post->user_id;
|
||||||
$this->last_post_id = $post->id;
|
$this->last_post_id = $post->id;
|
||||||
$this->last_post_number = $post->number;
|
$this->last_post_number = $post->number;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user