FEATURE: add language to content pages

This commit is contained in:
Michal Kváček
2016-07-22 14:55:51 +02:00
parent 2189bbed5e
commit f90aee4108
7 changed files with 107 additions and 14 deletions
+7
View File
@@ -5,6 +5,7 @@ namespace App\Models;
use App\Enumerations\ContentStatuses;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
/**
* Class Content
@@ -15,6 +16,7 @@ class Content extends Model
protected $fillable = [
'user_id',
'parent_id',
'language',
'module_handler',
'published_from',
'published_to',
@@ -53,6 +55,7 @@ class Content extends Model
public function getHomepage()
{
return $this->getPageQuery()
->where('language', LaravelLocalization::getCurrentLocale())
->where('is_homepage', 1)
->first();
}
@@ -68,6 +71,7 @@ class Content extends Model
{
return $this->getPageQuery()
->where('url', $url)
->where('language', LaravelLocalization::getCurrentLocale())
->first();
}
@@ -81,6 +85,7 @@ class Content extends Model
if (!$this->subpagesInit) {
$this->subpages = $this->getPageQuery()
->where('parent_id', $this->id)
->where('language', LaravelLocalization::getCurrentLocale())
->get();
// convert JSON settings into stdClass
@@ -142,6 +147,7 @@ class Content extends Model
public function rootPages()
{
$rootPages = $this->getPageQuery()
->where('language', LaravelLocalization::getCurrentLocale())
->where('parent_id', null);
if ($this->id) {
@@ -166,6 +172,7 @@ class Content extends Model
$query = DB::table('contents')
->select('contents.*', 'modules.name AS module_name')
->where('contents.status', '<>', self::STATUS_DELETED)
->where('contents.language', LaravelLocalization::getCurrentLocale())
->join('modules', 'modules.handler', '=', 'contents.module_handler')
->orderBy('created_at', 'DESC');