logo, improved listing, some helpers, mail confirms table, confirmed flag, user title column..

This commit is contained in:
2018-07-22 15:43:17 +02:00
parent 9081b38425
commit a3ba68ea98
47 changed files with 1462 additions and 292 deletions
+44 -16
View File
@@ -8,6 +8,8 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notification;
use MightyPork\Exceptions\ArgumentException;
use MightyPork\Exceptions\NotExistException;
/**
* A user in the application
@@ -19,16 +21,18 @@ use Illuminate\Notifications\Notification;
* @property string $title - for display
* @property string $email - unique, for login and social auth chaining
* @property string $password - hashed pw
* @property Proposal[]|Collection $proposals
* @property Table[]|Collection $tables
* @property OAuthIdentity[]|Collection $socialIdentities
* @property TableComment[]|Collection $tableComments
* @property Table[]|Collection $favouriteTables
* @property Table[]|Collection $followedDiscussions
* @property ContentReport[]|Collection $authoredReports
* @property Notification[]|Collection $notifications
* @property Notification[]|Collection $readNotifications
* @property Notification[]|Collection $unreadNotifications
* @property bool $confirmed - user e-mail is confirmed
* @property-read Proposal[]|Collection $proposals
* @property-read Table[]|Collection $tables
* @property-read OAuthIdentity[]|Collection $socialIdentities
* @property-read TableComment[]|Collection $tableComments
* @property-read Table[]|Collection $favouriteTables
* @property-read Table[]|Collection $followedDiscussions
* @property-read ContentReport[]|Collection $authoredReports
* @property-read Notification[]|Collection $notifications
* @property-read Notification[]|Collection $readNotifications
* @property-read Notification[]|Collection $unreadNotifications
* @property-read string $handle - user handle, including @
*/
class User extends Authenticatable
{
@@ -137,12 +141,36 @@ class User extends Authenticatable
$this->followedDiscussions()->detach($table);
}
public function fakeTables()
/**
* Resolve user by a given name, id, or e-mail
*
* @param string $ident
* @return User
*/
public static function resolve($ident)
{
return [
(object)['title' => 'Table 1'],
(object)['title' => 'Table 2'],
(object)['title' => 'Table 3']
];
$ident = "$ident";
if (strlen($ident) == 0) throw new ArgumentException("Can't find user by empty string.");
if (is_numeric($ident)) {
$u = static::find((int)$ident);
}
else if ($ident[0] == '@') {
$u = static::where('name', substr($ident, 1))->first();
}
else {
$u = static::where('email', $ident)->first();
}
if (!$u) throw new NotExistException("No user found matching \"$ident\"");
return $u;
}
public function __get($name)
{
if ($name == 'handle') return "@$this->name";
return parent::__get($name);
}
}