add doc comments to models

pull/26/head
Ondřej Hruška 6 years ago
parent f12773ccd1
commit 25cb60d377
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 10
      app/Models/ContentReport.php
  2. 51
      app/Models/Notification.php
  3. 15
      app/Models/Proposal.php
  4. 15
      app/Models/Revision.php
  5. 5
      app/Models/Row.php
  6. 24
      app/Models/Table.php
  7. 14
      app/Models/TableComment.php
  8. 6
      app/Models/User.php

@ -6,6 +6,16 @@ use Illuminate\Database\Eloquent\Model;
/**
* Report (something objectionable spotted by a user)
*
* @property int $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $object_type
* @property int $object_id
* @property int $author_id
* @property string $message
* @property User $author
* @property mixed $object - morph
*/
class ContentReport extends Model
{

@ -1,51 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Notification received by a user
*/
class Notification extends Model
{
/** Recipient user */
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
/** User who triggered this notification */
public function actor()
{
return $this->belongsTo(User::class, 'actor_id');
}
/** Notification context (what was affected) */
public function context()
{
return $this->morphTo();
}
/**
* Unseen notifications
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeUnseen($query)
{
return $query->where('seen', false);
}
/**
* Seen notifications
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeSeen($query)
{
return $query->where('seen', true);
}
}

@ -2,16 +2,23 @@
namespace App\Models;
use App\Models\Concerns\NotificationContext;
use App\Models\Concerns\Reportable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Change proposal
*
* @property Row[]|Collection $addedRows
* @property Row[]|Collection $removedRows
* @property int $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $table_id
* @property int $revision_id
* @property int $author_id
* @property string $note
* @property User $author
* @property Table $table
* @property Revision $revision
* @property object $changes - JSONB
*/
class Proposal extends Model
{

@ -3,10 +3,23 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Riesjart\Relaquent\Model\Concerns\HasRelaquentRelationships;
/**
* Table revision (a set of rows)
*
* @property int $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $refs
* @property int $ancestor_id
* @property string $note
* @property string $index_column
* @property Revision|null $parentRevision
* @property Row[]|Collection $rows
* @property Proposal|null $sourceProposal - proposal that was used to create this revision
* @property Proposal[]|Collection $dependentProposals
*/
class Revision extends Model
{
@ -29,7 +42,7 @@ class Revision extends Model
}
/** Proposal that lead to this revision */
public function appliedProposal()
public function sourceProposal()
{
return $this->hasOneThrough(Proposal::class, 'revision_proposal_pivot');
}

@ -6,7 +6,12 @@ use Illuminate\Database\Eloquent\Model;
/**
* Row in a data table
*
* @property int $id
* @property int $refs
* @property string $data - JSONB
*/
class Row extends Model
{
public $timestamps = false;
}

@ -2,12 +2,32 @@
namespace App\Models;
use App\Models\Concerns\NotificationContext;
use App\Models\Concerns\Reportable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* A data table object (referencing changesets and rows)
* A data table object (referencing revisions)
*
* @property int $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $owner_id
* @property int $ancestor_id
* @property int $revision_id
* @property string $title
* @property string $description
* @property string $license
* @property string $source_link
* @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
*/
class Table extends Model
{

@ -2,12 +2,24 @@
namespace App\Models;
use App\Models\Concerns\NotificationContext;
use App\Models\Concerns\Reportable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Comment on a data table
*
* @property int $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $table_id
* @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
*/
class TableComment extends Model
{

@ -4,7 +4,6 @@ namespace App\Models;
use AdamWathan\EloquentOAuth\OAuthIdentity;
use App\Models\Concerns\Reportable;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
@ -12,8 +11,9 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
/**
* A user in the application
*
* @property Carbon $created_at
* @property Carbon $updated_at
* @property int $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property string $name - unique, for vanity URL
* @property string $email - unique, for login and social auth chaining
* @property string $password - hashed pw

Loading…
Cancel
Save