From 062ce7b528466e43dc1ffc49ebacecc984b00415 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Aug 2023 21:21:42 +0500 Subject: [PATCH] from server --- .../api/BlogPostsApiController.php | 12 +++++ .../controllers/api/ProductsApiController.php | 5 ++ .../controllers/api/VendorApiController.php | 3 +- plugins/ahmadfatoni/apigenerator/routes.php | 2 + .../tps/birzha/controllers/Notification.php | 18 +++++++ .../notification/_list_toolbar.htm | 18 +++++++ .../controllers/notification/config_form.yaml | 10 ++++ .../controllers/notification/config_list.yaml | 12 +++++ .../controllers/notification/create.htm | 46 ++++++++++++++++ .../birzha/controllers/notification/index.htm | 1 + .../controllers/notification/preview.htm | 22 ++++++++ .../controllers/notification/update.htm | 54 +++++++++++++++++++ plugins/tps/birzha/models/Notification.php | 33 ++++++++++++ .../birzha/models/notification/columns.yaml | 13 +++++ .../birzha/models/notification/fields.yaml | 10 ++++ plugins/tps/birzha/plugin.yaml | 5 ++ ..._table_create_tps_birzha_notifications.php | 27 ++++++++++ plugins/tps/birzha/updates/version.yaml | 3 ++ 18 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 plugins/tps/birzha/controllers/Notification.php create mode 100644 plugins/tps/birzha/controllers/notification/_list_toolbar.htm create mode 100644 plugins/tps/birzha/controllers/notification/config_form.yaml create mode 100644 plugins/tps/birzha/controllers/notification/config_list.yaml create mode 100644 plugins/tps/birzha/controllers/notification/create.htm create mode 100644 plugins/tps/birzha/controllers/notification/index.htm create mode 100644 plugins/tps/birzha/controllers/notification/preview.htm create mode 100644 plugins/tps/birzha/controllers/notification/update.htm create mode 100644 plugins/tps/birzha/models/Notification.php create mode 100644 plugins/tps/birzha/models/notification/columns.yaml create mode 100644 plugins/tps/birzha/models/notification/fields.yaml create mode 100644 plugins/tps/birzha/updates/builder_table_create_tps_birzha_notifications.php diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php index 9d0a782..11931a8 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php @@ -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) { diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php index 9f9913b..583514b 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php @@ -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', diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/VendorApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/VendorApiController.php index 8d442ce..87b3cf3 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/VendorApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/VendorApiController.php @@ -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 [];} diff --git a/plugins/ahmadfatoni/apigenerator/routes.php b/plugins/ahmadfatoni/apigenerator/routes.php index 3ae1787..1c685e6 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -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'); diff --git a/plugins/tps/birzha/controllers/Notification.php b/plugins/tps/birzha/controllers/Notification.php new file mode 100644 index 0000000..ab1f496 --- /dev/null +++ b/plugins/tps/birzha/controllers/Notification.php @@ -0,0 +1,18 @@ + + + + diff --git a/plugins/tps/birzha/controllers/notification/config_form.yaml b/plugins/tps/birzha/controllers/notification/config_form.yaml new file mode 100644 index 0000000..3f8fe0b --- /dev/null +++ b/plugins/tps/birzha/controllers/notification/config_form.yaml @@ -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 diff --git a/plugins/tps/birzha/controllers/notification/config_list.yaml b/plugins/tps/birzha/controllers/notification/config_list.yaml new file mode 100644 index 0000000..5a34e84 --- /dev/null +++ b/plugins/tps/birzha/controllers/notification/config_list.yaml @@ -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' diff --git a/plugins/tps/birzha/controllers/notification/create.htm b/plugins/tps/birzha/controllers/notification/create.htm new file mode 100644 index 0000000..92c408d --- /dev/null +++ b/plugins/tps/birzha/controllers/notification/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/birzha/controllers/notification/index.htm b/plugins/tps/birzha/controllers/notification/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/tps/birzha/controllers/notification/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/plugins/tps/birzha/controllers/notification/preview.htm b/plugins/tps/birzha/controllers/notification/preview.htm new file mode 100644 index 0000000..2ebb96f --- /dev/null +++ b/plugins/tps/birzha/controllers/notification/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+ + +

+ + + +

\ No newline at end of file diff --git a/plugins/tps/birzha/controllers/notification/update.htm b/plugins/tps/birzha/controllers/notification/update.htm new file mode 100644 index 0000000..449039a --- /dev/null +++ b/plugins/tps/birzha/controllers/notification/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + + +
+
+ + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/birzha/models/Notification.php b/plugins/tps/birzha/models/Notification.php new file mode 100644 index 0000000..3daa992 --- /dev/null +++ b/plugins/tps/birzha/models/Notification.php @@ -0,0 +1,33 @@ +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'); + } +} diff --git a/plugins/tps/birzha/updates/version.yaml b/plugins/tps/birzha/updates/version.yaml index dcfc44d..71e3169 100644 --- a/plugins/tps/birzha/updates/version.yaml +++ b/plugins/tps/birzha/updates/version.yaml @@ -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