winter/modules/backend/models/UserPreference.php

41 lines
988 B
PHP
Raw Normal View History

2014-05-14 23:24:20 +10:00
<?php namespace Backend\Models;
use Exception;
use BackendAuth;
use October\Rain\Database\Model;
2015-01-28 18:03:35 +11:00
use SystemException;
2014-05-14 23:24:20 +10:00
use October\Rain\Auth\Models\Preferences as PreferencesBase;
2014-10-03 18:00:21 +10:00
/**
* All preferences for the backend user
*
* @package october\backend
* @author Alexey Bobkov, Samuel Georges
*/
class UserPreference extends PreferencesBase
2014-05-14 23:24:20 +10:00
{
/**
* @var string The database table used by the model.
*/
protected $table = 'backend_user_preferences';
public $timestamps = false;
protected static $cache = [];
/**
* Checks for a supplied user or uses the default logged in. You should override this method.
* @param mixed $user An optional back-end user object.
* @return User object
*/
public function resolveUser($user)
{
$user = BackendAuth::getUser();
2014-10-11 00:04:51 +02:00
if (!$user) {
2014-05-14 23:24:20 +10:00
throw new SystemException(trans('backend::lang.user.preferences.not_authenticated'));
2014-10-11 00:04:51 +02:00
}
2014-05-14 23:24:20 +10:00
return $user;
}
}