FIX: display only published pages - respect published_* settings
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Enumerations\ContentStatuses;
|
use App\Enumerations\ContentStatuses;
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
@@ -64,6 +65,14 @@ class Content extends Model
|
|||||||
->select('contents.*')
|
->select('contents.*')
|
||||||
->with('author')
|
->with('author')
|
||||||
->join('modules', 'modules.handler', '=', 'contents.module_handler')
|
->join('modules', 'modules.handler', '=', 'contents.module_handler')
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->where('published_from', '>', Carbon::now())
|
||||||
|
->orWhereNull('published_from');
|
||||||
|
})
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->where('published_to', '<', Carbon::now())
|
||||||
|
->orWhereNull('published_to');
|
||||||
|
})
|
||||||
->where('language', LaravelLocalization::getCurrentLocale())
|
->where('language', LaravelLocalization::getCurrentLocale())
|
||||||
->where('modules.enabled', true);
|
->where('modules.enabled', true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Content;
|
use App\Models\Content;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Input;
|
use Illuminate\Support\Facades\Input;
|
||||||
@@ -98,6 +99,14 @@ class ArticleList extends Handler
|
|||||||
$articles = ArticleModel::where('module_handler', Article::class)
|
$articles = ArticleModel::where('module_handler', Article::class)
|
||||||
->with('comments')
|
->with('comments')
|
||||||
->with('category')
|
->with('category')
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->where('published_from', '>', Carbon::now())
|
||||||
|
->orWhereNull('published_from');
|
||||||
|
})
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->where('published_to', '<', Carbon::now())
|
||||||
|
->orWhereNull('published_to');
|
||||||
|
})
|
||||||
->orderBy('published_from', 'DESC')
|
->orderBy('published_from', 'DESC')
|
||||||
->orderBy('created_at', 'DESC');
|
->orderBy('created_at', 'DESC');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user