Use pre-loaded state if applicable. closes flarum/core#89

This commit is contained in:
Toby Zerner 2015-06-01 12:26:11 +09:30
parent 3eed9a99b6
commit 761b76539d

View File

@ -295,6 +295,11 @@ class Discussion extends Model
*/
public function stateFor(User $user)
{
$loadedState = array_get($this->relations, 'state');
if ($loadedState && $loadedState->user_id === $user->id) {
return $loadedState;
}
$state = $this->state($user)->first();
if (! $state) {