Repository URL to install this package:
|
Version:
3.2.3 ▾
|
<?php
namespace Evsmash\Articles\Http;
use Evsmash\Core\Http\Base;
use Evsmash\Core\Input\Flash;
use Evsmash\Core\Input\Route;
use Evsmash\Core\Input\Post;
use Evsmash\Core\Simpy\Element;
use Evsmash\Core\System\Trans;
use Evsmash\Articles\Article;
use Evsmash\Articles\ArticlesCategory;
use Evsmash\Articles\ArticlesType;
class Articles extends Base {
// index
public function index() {
// elements
$elements = Article::params()->published()->month(Route::get('month'))->with('type')->with('categories')->paginate($this->settings->limit);
// trans
Trans::get($elements, 'articles');
// flash
if(Route::get('month')) {
Flash::set('robots', 'noindex, follow');
}
// view
$this->seo($elements);
$this->breadcrumbs();
$this->viewTitle('Articles');
$this->view(compact(['elements']));
}
// type
public function type() {
// type
$type = Element::check(new ArticlesType);
// element
$elements = Article::params()->published()->where('type_id', $type->id)->with('type')->with('categories')->paginate($this->settings->limit);
// trans
Trans::get($type, 'articles_types');
Trans::get($elements, 'articles');
// flash
Flash::set('type', $type->id);
// view
$this->seo($type);
$this->seo($elements);
$this->breadcrumbs($type);
$this->viewTitle($type->name);
$this->view(compact(['elements']), 'evsmash/articles/articles/index');
}
// category
public function category() {
// category
$category = Element::check(new ArticlesCategory);
// elements
$elements = $category->articles()->params()->published()->with('type')->with('categories')->paginate($this->settings->limit);
// trans
Trans::get($category, 'articles_categories');
Trans::get($elements, 'articles');
// flash
Flash::set('categories', [$category->id => $category->name]);
// view
$this->seo($category);
$this->seo($elements);
$this->breadcrumbs($category);
$this->viewTitle($category->name);
$this->view(compact(['elements', 'category']), 'evsmash/articles/articles/index');
}
// promoted
public function promoted() {
// elements
$elements = Article::params()->promoted()->published()->with('type')->with('categories')->paginate($this->settings->limit);
// trans
Trans::get($elements, 'articles');
// view
$this->seo($elements);
$this->breadcrumbs();
$this->viewTitle('Promoted articles');
$this->view(compact(['elements']), 'evsmash/articles/articles/index');
}
// show
public function show() {
// element
$element = Element::check(new Article);
// allowed
Element::allowed($element, 'published');
// stats
Element::stats($element);
// trans
Trans::get($element, 'articles');
// flash
Flash::set('type', $element->type_id);
Flash::set('categories', $element->categories->pluck('name', 'id'));
// view
$this->seo($element);
$this->breadcrumbs($element);
$this->viewTitle($element->name);
$this->viewDescription($element->sneak);
$this->viewPhoto($element->photo);
$this->view(compact(['element']));
}
}