From befb95a4ace0313cd9a69587c8c6ca70bdbd60b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Sat, 13 Aug 2016 19:02:58 +0200 Subject: [PATCH] FEATURE: add relationship methods to categories and content --- app/Models/Content.php | 6 ++++++ modules/Categories/Entities/Category.php | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Models/Content.php b/app/Models/Content.php index 0a5384b4..4fec44d0 100644 --- a/app/Models/Content.php +++ b/app/Models/Content.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; use Mcamara\LaravelLocalization\Facades\LaravelLocalization; +use Modules\Categories\Entities\Category; /** * Class Content @@ -407,6 +408,11 @@ class Content extends Model return $this->belongsToMany(File::class, 'contents_has_files'); } + public function category() + { + return $this->belongsTo(Category::class); + } + /** * Save history entry into database * diff --git a/modules/Categories/Entities/Category.php b/modules/Categories/Entities/Category.php index 7f36e6cf..65cfce27 100644 --- a/modules/Categories/Entities/Category.php +++ b/modules/Categories/Entities/Category.php @@ -1,6 +1,7 @@ belongsTo(Module::class); } + + public function content() + { + return $this->hasMany(Content::class); + } }