This commit is contained in:
2020-08-08 20:44:59 +05:00
parent 7dd62e46c0
commit 6103cf19ec
3 changed files with 68 additions and 0 deletions

44
app/Article.php Normal file
View 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
View 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
View File

@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Topic extends Model
{
//
}