Models
This commit is contained in:
44
app/Article.php
Normal file
44
app/Article.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use GoldSpecDigital\LaravelEloquentUUID\Database\Eloquent\Uuid;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use App\Source;
|
||||||
|
use App\Topic;
|
||||||
|
|
||||||
|
class Article extends Model
|
||||||
|
{
|
||||||
|
use Uuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "type" of the auto-incrementing ID.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $keyType = 'string';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the IDs are auto-incrementing.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $incrementing = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function source()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Source::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function topics()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Topic::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
app/Source.php
Normal file
14
app/Source.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use App\Article;
|
||||||
|
|
||||||
|
class Source extends Model
|
||||||
|
{
|
||||||
|
public function articles()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Article::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/Topic.php
Normal file
10
app/Topic.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Topic extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user