Feuerwehr-eppingen/app/Http/Controllers/ArticleController.php

171 lines
3.5 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\Tag;
use App\Helpers\StringHelper;
class ArticleController extends PostController
{
public function __construct()
{
$this->middleware(['auth' => 'articlePermissions'])->except('index', 'show');
// Model
$this->modelType = StringHelper::toURL(__('models.article'));
$this->modelData = [
'departments' => [
'type' => 'inputSelect',
'name' => 'tags',
'label' => __('models.department'),
'foreign' => [
'class' => Tag::class,
'model' => 'tags',
'column' => 'name',
'order' => [
'column' => 'order',
'direction' => 'ASC'
],
'conditions' => [
[
'column' => 'type',
'value' => 'abteilung',
],
],
],
],
'instances' => [
'type' => 'inputSelect',
'name' => 'tags',
'label' => __('models.instance'),
'foreign' => [
'class' => Tag::class,
'model' => 'tags',
'column' => 'name',
'order' => [
'column' => 'name',
'direction' => 'ASC'
],
'conditions' => [
[
'column' => 'type',
'value' => 'instanz',
],
],
],
],
'title' => [
'type' => 'inputText',
'label' => __('models.title'),
'placeholder' => __('models.title'),
'validation' => [
'rules' => 'required|min:3',
]
],
'content' => [
'type' => 'inputTextarea',
'label' => __('models.text'),
'placeholder' => __('models.text'),
'toolbar' => [
[
'insertfile',
'undo',
'redo',
],
[
'bold',
'italic',
'strikethrough'
],
[
'link'
]
],
'plugins' =>
[
'paste',
'link'
],
'validation' => [
'rules' => 'required',
]
],
];
// URL options
$this->url = 'article';
$this->route = StringHelper::toURL(__('models.article'));
$this->indexOptions = [
'orderBy' => 'datetime',
'orderDirection' => 'DESC',
'paginate' => 9,
'view' => 'inc.views.cardPreviewContainer2',
'filter' => [
'departments'=> [
'type' => 'select',
],
'instances'=> [
'type' => 'select',
],
'year' => [
'type' => 'select',
'label' => __('general.year'),
'name' => strtolower(__('general.year'))
],
'month' => [
'type' => 'select',
'label' => __('general.month'),
'name' => strtolower(__('general.month'))
],
]
];
$this->detailsOptions = [
'view' => 'inc.views.details',
'newest' => [
'limit' => 3,
'label' => __('models.current articles')
],
'further' => [
'limit' => 3,
'label' => __('models.older articles')
],
];
$this->adminIndexOptions = [
'orderBy' => 'datetime',
'orderDirection' => 'DESC',
'paginate' => 10,
'listdata' => [
'title' => [],
'departments' => [],
'user' => [
'label' => __('general.author'),
'foreign' => [
'model' => 'audits',
'column' => 'name',
'index' => 'last'
],
],
'datetime' => [
'label' => __('general.datetime'),
'format' => __('general.datetime_format_short')
],
'published' => [
'label' => __('admin.published'),
]
]
];
// Publishing
$this->publishOptions = [
'date' => '-1w'
];
parent::__construct();
}
}