init
This commit is contained in:
16
app/Models/Article.php
Normal file
16
app/Models/Article.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Article extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
function audit()
|
||||
{
|
||||
return $this->hasOne(ArticleAudit::class);
|
||||
}
|
||||
}
|
||||
18
app/Models/ArticleAudit.php
Normal file
18
app/Models/ArticleAudit.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class ArticleAudit extends Model
|
||||
{
|
||||
|
||||
function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
function article()
|
||||
{
|
||||
return $this->belongsTo(Article::class);
|
||||
}
|
||||
|
||||
}
|
||||
28
app/Models/Item.php
Normal file
28
app/Models/Item.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* Notes: 所属投票场次
|
||||
* @Author: <C.Jason>
|
||||
* @Date: 2020/5/1 23:52
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function vote(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Vote::class);
|
||||
}
|
||||
|
||||
public function logs()
|
||||
{
|
||||
return $this->hasMany(ItemLog::class);
|
||||
}
|
||||
|
||||
}
|
||||
18
app/Models/ItemLog.php
Normal file
18
app/Models/ItemLog.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class ItemLog extends Model
|
||||
{
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
|
||||
}
|
||||
13
app/Models/Model.php
Normal file
13
app/Models/Model.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use DateTimeInterface;
|
||||
|
||||
class Model extends \Illuminate\Database\Eloquent\Model
|
||||
{
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
}
|
||||
37
app/Models/User.php
Normal file
37
app/Models/User.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Jason\Api\Traits\ApiGuardable;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
|
||||
use Notifiable,
|
||||
ApiGuardable;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(__CLASS__);
|
||||
}
|
||||
|
||||
public function setParentIdAttribute($value)
|
||||
{
|
||||
if ($value) {
|
||||
$this->attributes['parent_id'] = $value;
|
||||
} else {
|
||||
$this->attributes['parent_id'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
26
app/Models/Vote.php
Normal file
26
app/Models/Vote.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Vote extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $casts = [
|
||||
'archives' => 'json',
|
||||
];
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(Item::class);
|
||||
}
|
||||
|
||||
public function logs()
|
||||
{
|
||||
return $this->hasMany(ItemLog::class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user