from server

This commit is contained in:
root 2023-08-03 21:21:42 +05:00
parent bd0bdad6f4
commit 062ce7b528
18 changed files with 293 additions and 1 deletions

View File

@ -15,6 +15,7 @@ use TPS\Birzha\Models\UserSliders;
use TPS\Birzha\Models\Product;
use TPS\Birzha\Models\City;
use TPS\Birzha\Models\Favourites;
use TPS\Birzha\Models\Notification;
use TPS\Birzha\Models\Comment;
use RainLab\User\Models\User;
@ -51,6 +52,17 @@ class BlogPostsApiController extends Controller
->orderBy('published_at', $data['sort_order'] ?? 'desc')
->paginate($data['per_page'] ?? 7))->response()->getData(), 200);
}
public function getNotifications(){
$data = Notification::with([
'translations:locale,model_id,attribute_data'
])->paginate(9);
return $this->helpers->apiArrayResponseBuilder(200, 'ok', [$data]);
}
public function getAccountSliders($id)
{

View File

@ -124,6 +124,11 @@ class ProductsAPIController extends Controller
}
public function show($id){
$product = Product::find($id);
$product->number_of_views++;
$product->save();
$data = $this->Product::with([
'translations:locale,model_id,attribute_data',

View File

@ -5,7 +5,7 @@ use Illuminate\Http\Request;
use AhmadFatoni\ApiGenerator\Helpers\Helpers;
use Illuminate\Support\Facades\Validator;
//use TPS\Birzha\Models\Term;
use TPS\Birzha\Models\Notification;
use RainLab\User\Models\User as Vendor;
class VendorApiController extends Controller
@ -61,6 +61,7 @@ class VendorApiController extends Controller
}
}
public static function getAfterFilters() {return [];}
public static function getBeforeFilters() {return [];}

View File

@ -35,6 +35,8 @@ Route::group(['prefix' =>'api/v1','namespace' =>'AhmadFatoni\ApiGenerator\Contro
// Route::get('account/{id}/sliders', 'BlogPostsApiController@getAccountSliders')->where(['id' => '[0-9]+']);
Route::get('account/{id}/products', 'BlogPostsApiController@getAccountProducts')->where(['id' => '[0-9]+']);
Route::get('account/{id}/datas', 'BlogPostsApiController@getAccountDatas');
Route::get('notifications', 'BlogPostsApiController@getNotifications');
Route::middleware(['\Tymon\JWTAuth\Middleware\GetUserFromToken'])->group(function () {
Route::post('update/vendor/data', 'VendorApiController@updateVendor');

View File

@ -0,0 +1,18 @@
<?php namespace TPS\Birzha\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
class Notification 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.Birzha', 'contact-messages', 'side-menu-item');
}
}

View File

@ -0,0 +1,18 @@
<div data-control="toolbar">
<a href="<?= Backend::url('tps/birzha/notification/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>

View File

@ -0,0 +1,10 @@
name: Notification
form: $/tps/birzha/models/notification/fields.yaml
modelClass: TPS\Birzha\Models\Notification
defaultRedirect: tps/birzha/notification
create:
redirect: 'tps/birzha/notification/update/:id'
redirectClose: tps/birzha/notification
update:
redirect: tps/birzha/notification
redirectClose: tps/birzha/notification

View File

@ -0,0 +1,12 @@
list: $/tps/birzha/models/notification/columns.yaml
modelClass: TPS\Birzha\Models\Notification
title: Notification
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/birzha/notification/update/:id'

View File

@ -0,0 +1,46 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('tps/birzha/notification') ?>">Notification</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/birzha/notification') ?>"><?= 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/birzha/notification') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
<?php endif ?>

View File

@ -0,0 +1 @@
<?= $this->listRender() ?>

View File

@ -0,0 +1,22 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('tps/birzha/notification') ?>">Notification</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/birzha/notification') ?>" class="btn btn-default oc-icon-chevron-left">
<?= e(trans('backend::lang.form.return_to_list')) ?>
</a>
</p>

View File

@ -0,0 +1,54 @@
<?php Block::put('breadcrumb') ?>
<ul>
<li><a href="<?= Backend::url('tps/birzha/notification') ?>">Notification</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/birzha/notification') ?>"><?= 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/birzha/notification') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>
<?php endif ?>

View File

@ -0,0 +1,33 @@
<?php namespace TPS\Birzha\Models;
use Model;
/**
* Model
*/
class Notification extends Model
{
use \October\Rain\Database\Traits\Validation;
use \October\Rain\Database\Traits\SoftDelete;
public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel'];
public $translatable = [
'subject', 'text',
];
protected $dates = ['deleted_at'];
/**
* @var string The database table used by the model.
*/
public $table = 'tps_birzha_notifications';
/**
* @var array Validation rules
*/
public $rules = [
];
}

View File

@ -0,0 +1,13 @@
columns:
created_at:
label: created_at
type: datetime
updated_at:
label: updated_at
type: datetime
subject:
label: subject
type: text
text:
label: text
type: text

View File

@ -0,0 +1,10 @@
fields:
subject:
label: Subject
span: auto
type: text
text:
label: Text
span: auto
size: huge
type: richeditor

View File

@ -88,6 +88,11 @@ navigation:
icon: icon-inbox
permissions:
- contactformmsgs
sideMenu:
side-menu-item:
label: Notifications
url: tps/birzha/notification
icon: icon-bullhorn
permissions:
category:
tab: Catalog

View File

@ -0,0 +1,27 @@
<?php namespace TPS\Birzha\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateTpsBirzhaNotifications extends Migration
{
public function up()
{
Schema::create('tps_birzha_notifications', 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->string('subject')->nullable();
$table->text('text')->nullable();
$table->dateTime('read_at')->nullable();
});
}
public function down()
{
Schema::dropIfExists('tps_birzha_notifications');
}
}

View File

@ -392,3 +392,6 @@
1.0.137:
- 'Updated table tps_birzha_messages'
- builder_table_update_tps_birzha_messages_2.php
1.0.138:
- 'Created table tps_birzha_notifications'
- builder_table_create_tps_birzha_notifications.php