mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Use pre-loaded state if applicable. closes flarum/core#89
This commit is contained in:
parent
3eed9a99b6
commit
761b76539d
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user