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
+1 -1
View File
@@ -14,8 +14,8 @@ use Illuminate\Database\Eloquent\Model;
* @property int $object_id
* @property int $author_id
* @property string $message
* @property User $author
* @property mixed $object - morph
* @property-read User $author
*/
class ContentReport extends Model
{
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* E-mail confirmation
*
* @property int $id
* @property \Carbon\Carbon $created_at
* @property int $user_id
* @property string $token
* @property-read User $user
*/
class EmailConfirmation extends Model
{
protected $guarded = [];
const UPDATED_AT = null; // disable update timestamp
/** Authoring user */
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
}
+3 -3
View File
@@ -15,10 +15,10 @@ use Illuminate\Database\Eloquent\Model;
* @property int $revision_id
* @property int $author_id
* @property string $note
* @property User $author
* @property Table $table
* @property Revision $revision
* @property object $changes - JSONB
* @property-read User $author
* @property-read Table $table
* @property-read Revision $revision
*/
class Proposal extends Model
{
+5 -4
View File
@@ -15,10 +15,11 @@ use Riesjart\Relaquent\Model\Concerns\HasRelaquentRelationships;
* @property int $ancestor_id
* @property string $note
* @property object $columns
* @property Revision|null $parentRevision
* @property Row[]|Collection $rows
* @property Proposal|null $sourceProposal - proposal that was used to create this revision
* @property Proposal[]|Collection $dependentProposals
* @property int $row_count - cached number of rows in the revision
* @property-read Revision|null $parentRevision
* @property-read Row[]|Collection $rows
* @property-read Proposal|null $sourceProposal - proposal that was used to create this revision
* @property-read Proposal[]|Collection $dependentProposals
*/
class Revision extends Model
{
+12 -10
View File
@@ -2,9 +2,11 @@
namespace App\Models;
use App\Models\Concerns\ManyManyThrough;
use App\Models\Concerns\Reportable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Riesjart\Relaquent\Model\Concerns\HasRelaquentRelationships;
/**
* A data table object (referencing revisions)
@@ -20,15 +22,15 @@ use Illuminate\Database\Eloquent\Model;
* @property string $description
* @property string $license
* @property string $origin
* @property User $owner
* @property Table $parentTable
* @property Table[]|Collection $forks
* @property Revision[]|Collection $revisions
* @property Revision $activeRevision
* @property Proposal[]|Collection $proposal
* @property TableComment[]|Collection $comments
* @property User[]|Collection $favouritingUsers
* @property User[]|Collection $discussionFollowers
* @property-read User $owner
* @property-read Table $parentTable
* @property-read Table[]|Collection $forks
* @property-read Revision[]|Collection $revisions
* @property-read Revision $revision
* @property-read Proposal[]|Collection $proposal
* @property-read TableComment[]|Collection $comments
* @property-read User[]|Collection $favouritingUsers
* @property-read User[]|Collection $discussionFollowers
*/
class Table extends Model
{
@@ -60,7 +62,7 @@ class Table extends Model
}
/** Active revision */
public function activeRevision()
public function revision()
{
return $this->belongsTo(Revision::class, 'revision_id');
}
+4 -4
View File
@@ -16,10 +16,10 @@ use Illuminate\Database\Eloquent\Model;
* @property int $author_id
* @property int $ancestor_id
* @property string $message
* @property User $author
* @property Table $table
* @property TableComment|null $ancestor
* @property TableComment[]|Collection $replies
* @property-read User $author
* @property-read Table $table
* @property-read TableComment|null $ancestor
* @property-read TableComment[]|Collection $replies
*/
class TableComment extends Model
{
+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);
}
}