Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit Get User Creator Function #256

Merged
merged 1 commit into from
Oct 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/Models/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ class Thread extends Eloquent
* @var array
*/
protected $dates = ['deleted_at'];


/**
* Creator of Thread
*
* @User null
*/
protected $creator = null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 4 spaces, found 5


/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -96,9 +103,11 @@ public function users()
*/
public function creator()
{
$firstMessage = $this->messages()->withTrashed()->oldest()->first();

return $firstMessage ? $firstMessage->user : null;
if (is_null($this->creator)) {
$firstMessage = $this->messages()->withTrashed()->oldest()->first();
$this->creator = $firstMessage ? $firstMessage->user : null;
}
return $this->creator;
}

/**
Expand Down