about us content
This commit is contained in:
parent
6866f94346
commit
a6759242f6
|
|
@ -0,0 +1,58 @@
|
|||
<?php namespace AhmadFatoni\ApiGenerator\Controllers\API;
|
||||
|
||||
use Cms\Classes\Controller;
|
||||
use BackendMenu;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use AhmadFatoni\ApiGenerator\Helpers\Helpers;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Tps\Hhm\Models\Contents;
|
||||
use Tps\Hhm\Classes\ContentResource;
|
||||
|
||||
|
||||
class ContentsController extends Controller
|
||||
{
|
||||
protected $Contents;
|
||||
|
||||
protected $helpers;
|
||||
|
||||
public function __construct(Contents $Contents, Helpers $helpers)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->Contents = $Contents;
|
||||
$this->helpers = $helpers;
|
||||
}
|
||||
|
||||
public function index(Request $request){
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
$validator = Validator::make($data, [
|
||||
'locale' => 'required|in:ru,en,tm',
|
||||
'type' => 'required'
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validator->errors() );
|
||||
}
|
||||
|
||||
$contentType = $request->get('type');
|
||||
|
||||
$data = response()->json(
|
||||
ContentResource::collection($this->Contents::where("type", $contentType)->get()));
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getAfterFilters() {return [];}
|
||||
public static function getBeforeFilters() {return [];}
|
||||
public static function getMiddleware() {return [];}
|
||||
public function callAction($method, $parameters=false) {
|
||||
return call_user_func_array(array($this, $method), $parameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,3 +9,5 @@ Route::get('api/v1/categories/{id}/delete', ['as' => 'api/v1/categories.delete',
|
|||
|
||||
Route::resource('api/v1/posts', 'AhmadFatoni\ApiGenerator\Controllers\API\PostsController', ['except' => ['destroy', 'create', 'edit']]);
|
||||
Route::get('api/v1/posts/{id}/delete', ['as' => 'api/v1/posts.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\PostsController@destroy']);
|
||||
|
||||
Route::resource('api/v1/content', 'AhmadFatoni\ApiGenerator\Controllers\API\ContentsController', ['except' => ['destroy', 'create', 'edit']]);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
<?php namespace Tps\Hhm;
|
||||
|
||||
use System\Classes\PluginBase;
|
||||
|
||||
class Plugin extends PluginBase
|
||||
{
|
||||
public function registerComponents()
|
||||
{
|
||||
}
|
||||
|
||||
public function registerSettings()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Tps\Hhm\Classes;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ContentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$locale = $request->get('locale');
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'content' => $this->getAttributeTranslated('content', $locale),
|
||||
'type' => $this->type
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?php namespace Tps\Hhm\Controllers;
|
||||
|
||||
use Backend\Classes\Controller;
|
||||
use BackendMenu;
|
||||
|
||||
class Contents extends Controller
|
||||
{
|
||||
public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController' ];
|
||||
|
||||
public $listConfig = 'config_list.yaml';
|
||||
public $formConfig = 'config_form.yaml';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
BackendMenu::setContext('Tps.Hhm', 'main-menu-item');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<div data-control="toolbar">
|
||||
<a href="<?= Backend::url('tps/hhm/contents/create') ?>" class="btn btn-primary oc-icon-plus"><?= e(trans('backend::lang.form.create')) ?></a>
|
||||
<button
|
||||
class="btn btn-default oc-icon-trash-o"
|
||||
disabled="disabled"
|
||||
onclick="$(this).data('request-data', {
|
||||
checked: $('.control-list').listWidget('getChecked')
|
||||
})"
|
||||
data-request="onDelete"
|
||||
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
|
||||
data-trigger-action="enable"
|
||||
data-trigger=".control-list input[type=checkbox]"
|
||||
data-trigger-condition="checked"
|
||||
data-request-success="$(this).prop('disabled', true)"
|
||||
data-stripe-load-indicator>
|
||||
<?= e(trans('backend::lang.list.delete_selected')) ?>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
name: Contents
|
||||
form: $/tps/hhm/models/contents/fields.yaml
|
||||
modelClass: Tps\Hhm\Models\Contents
|
||||
defaultRedirect: tps/hhm/contents
|
||||
create:
|
||||
redirect: 'tps/hhm/contents/update/:id'
|
||||
redirectClose: tps/hhm/contents
|
||||
update:
|
||||
redirect: tps/hhm/contents
|
||||
redirectClose: tps/hhm/contents
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
list: $/tps/hhm/models/contents/columns.yaml
|
||||
modelClass: Tps\Hhm\Models\Contents
|
||||
title: Contents
|
||||
noRecordsMessage: 'backend::lang.list.no_records'
|
||||
showSetup: true
|
||||
showCheckboxes: true
|
||||
recordsPerPage: 20
|
||||
toolbar:
|
||||
buttons: list_toolbar
|
||||
search:
|
||||
prompt: 'backend::lang.list.search_prompt'
|
||||
recordUrl: 'tps/hhm/contents/update/:id'
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/hhm/contents') ?>">Contents</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class' => 'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.create')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-request="onSave"
|
||||
data-request-data="close:1"
|
||||
data-hotkey="ctrl+enter, cmd+enter"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-default">
|
||||
<?= e(trans('backend::lang.form.create_and_close')) ?>
|
||||
</button>
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('tps/hhm/contents') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('tps/hhm/contents') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<?= $this->listRender() ?>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/hhm/contents') ?>">Contents</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<div class="form-preview">
|
||||
<?= $this->formRenderPreview() ?>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e($this->fatalError) ?></p>
|
||||
<?php endif ?>
|
||||
|
||||
<p>
|
||||
<a href="<?= Backend::url('tps/hhm/contents') ?>" class="btn btn-default oc-icon-chevron-left">
|
||||
<?= e(trans('backend::lang.form.return_to_list')) ?>
|
||||
</a>
|
||||
</p>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php Block::put('breadcrumb') ?>
|
||||
<ul>
|
||||
<li><a href="<?= Backend::url('tps/hhm/contents') ?>">Contents</a></li>
|
||||
<li><?= e($this->pageTitle) ?></li>
|
||||
</ul>
|
||||
<?php Block::endPut() ?>
|
||||
|
||||
<?php if (!$this->fatalError): ?>
|
||||
|
||||
<?= Form::open(['class' => 'layout']) ?>
|
||||
|
||||
<div class="layout-row">
|
||||
<?= $this->formRender() ?>
|
||||
</div>
|
||||
|
||||
<div class="form-buttons">
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="submit"
|
||||
data-request="onSave"
|
||||
data-request-data="redirect:0"
|
||||
data-hotkey="ctrl+s, cmd+s"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-primary">
|
||||
<?= e(trans('backend::lang.form.save')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-request="onSave"
|
||||
data-request-data="close:1"
|
||||
data-hotkey="ctrl+enter, cmd+enter"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
|
||||
class="btn btn-default">
|
||||
<?= e(trans('backend::lang.form.save_and_close')) ?>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="oc-icon-trash-o btn-icon danger pull-right"
|
||||
data-request="onDelete"
|
||||
data-load-indicator="<?= e(trans('backend::lang.form.deleting')) ?>"
|
||||
data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')) ?>">
|
||||
</button>
|
||||
|
||||
<span class="btn-text">
|
||||
<?= e(trans('backend::lang.form.or')) ?> <a href="<?= Backend::url('tps/hhm/contents') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?= Form::close() ?>
|
||||
|
||||
<?php else: ?>
|
||||
<p class="flash-message static error"><?= e(trans($this->fatalError)) ?></p>
|
||||
<p><a href="<?= Backend::url('tps/hhm/contents') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
|
||||
<?php endif ?>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?php return [
|
||||
'plugin' => [
|
||||
'name' => 'HHM',
|
||||
'description' => ''
|
||||
]
|
||||
];
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php namespace Tps\Hhm\Models;
|
||||
|
||||
use Model;
|
||||
|
||||
/**
|
||||
* Model
|
||||
*/
|
||||
class Contents extends Model
|
||||
{
|
||||
use \October\Rain\Database\Traits\Validation;
|
||||
|
||||
use \October\Rain\Database\Traits\SoftDelete;
|
||||
|
||||
public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public $translatable = [
|
||||
'content',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @var string The database table used by the model.
|
||||
*/
|
||||
public $table = 'tps_hhm_contents';
|
||||
|
||||
/**
|
||||
* @var array Validation rules
|
||||
*/
|
||||
public $rules = [
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
columns:
|
||||
id:
|
||||
label: id
|
||||
type: number
|
||||
created_at:
|
||||
label: created_at
|
||||
type: datetime
|
||||
type:
|
||||
label: type
|
||||
type: text
|
||||
note:
|
||||
label: note
|
||||
type: text
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
fields:
|
||||
type:
|
||||
label: Type
|
||||
options:
|
||||
about: About
|
||||
span: auto
|
||||
default: about
|
||||
type: balloon-selector
|
||||
content:
|
||||
label: Content
|
||||
span: auto
|
||||
type: richeditor
|
||||
note:
|
||||
label: Note
|
||||
span: auto
|
||||
type: textarea
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
plugin:
|
||||
name: 'tps.hhm::lang.plugin.name'
|
||||
description: 'tps.hhm::lang.plugin.description'
|
||||
author: TPS
|
||||
icon: oc-icon-align-justify
|
||||
homepage: ''
|
||||
navigation:
|
||||
main-menu-item:
|
||||
label: 'About Us'
|
||||
url: tps/hhm/contents
|
||||
icon: icon-newspaper-o
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php namespace Tps\Hhm\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableCreateTpsHhmContents extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('tps_hhm_contents', function($table)
|
||||
{
|
||||
$table->engine = 'InnoDB';
|
||||
$table->increments('id')->unsigned();
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->timestamp('updated_at')->nullable();
|
||||
$table->timestamp('deleted_at')->nullable();
|
||||
$table->text('content')->nullable();
|
||||
$table->text('type')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('tps_hhm_contents');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
1.0.1:
|
||||
- 'Initialize plugin.'
|
||||
1.0.2:
|
||||
- 'Created table tps_hhm_contents'
|
||||
- builder_table_create_tps_hhm_contents.php
|
||||
Loading…
Reference in New Issue