From 6e478ce10fa520f717931bded7e3fb3ed39e5659 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Wed, 18 Dec 2024 04:04:48 +0330 Subject: [PATCH] added rss feed to project --- app/Http/Controllers/ClientController.php | 24 +++++++++++++++++++ composer.json | 1 + config/app.php | 2 +- .../segments/menu/HomayonMenu/HomayonMenu.php | 16 +++++++++++-- .../menu/HomayonMenu/HomayonMenu.scss | 2 +- .../views/website/inc/website-head.blade.php | 2 ++ resources/views/website/rss/post.blade.php | 19 +++++++++++++++ resources/views/website/rss/product.blade.php | 19 +++++++++++++++ routes/web.php | 2 ++ 9 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 resources/views/website/rss/post.blade.php create mode 100644 resources/views/website/rss/product.blade.php diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index e65751c..55ca080 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -868,4 +868,28 @@ class ClientController extends Controller 'message' => __('Your rate registered'), ]; } + + + public function postRss(){ + // Fetch the latest posts from the database + $posts = Post::orderBy('created_at', 'desc')->take(10)->get(); // Adjust the number of posts as needed + + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.rss.post',compact('posts'))->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); + } + public function productRss(){ + // Fetch the latest products from the database + $products = Product::orderBy('created_at', 'desc')->take(10)->get(); // Adjust the number of posts as needed + + $xmlContent = '' . PHP_EOL; + $xmlContent .= view('website.rss.product',compact('products'))->render(); // Render the view and append to XML content + + // Return the XML response + return response($xmlContent, 200) + ->header('Content-Type', 'text/xml'); + } } diff --git a/composer.json b/composer.json index 04f8e99..9658d12 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,7 @@ "description": "Very customizable and easy to use shopping system, open source project based on laravel", "keywords": ["xshop", "e-shop", "laravel","laravel-shop","open-source-shop"], "license": "GPL-3.0-or-later", + "version": "2.3.0", "require": { "php": "^8.2", "ext-dom": "*", diff --git a/config/app.php b/config/app.php index 5dce2cd..144cd33 100644 --- a/config/app.php +++ b/config/app.php @@ -16,7 +16,7 @@ return [ */ 'name' => env('APP_NAME', 'xShop'), - 'version' => env('APP_VERSION', '2.0.0'), + 'version' => env('APP_VERSION', '2.3.0'), 'demo' => env('APP_DEMO', false), /* |-------------------------------------------------------------------------- diff --git a/resources/views/segments/menu/HomayonMenu/HomayonMenu.php b/resources/views/segments/menu/HomayonMenu/HomayonMenu.php index 85b2d91..b73016a 100644 --- a/resources/views/segments/menu/HomayonMenu/HomayonMenu.php +++ b/resources/views/segments/menu/HomayonMenu/HomayonMenu.php @@ -16,7 +16,7 @@ class HomayonMenu $setting->section = 'theme'; $setting->key = $part->area_name . '_' . $part->part.'_title'; $setting->value = __("Shop"); - $setting->size = 6; + $setting->size = 4; $setting->type = 'TEXT'; // $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]); $setting->title = $part->area_name . ' ' . $part->part. ' title'; @@ -27,12 +27,23 @@ class HomayonMenu $setting->key = $part->area_name . '_' . $part->part.'_menu'; $setting->value = Menu::first()->id; $setting->type = 'MENU'; - $setting->size = 6; + $setting->size = 4; $setting->title = $part->area_name . ' ' . $part->part .' menu'; $setting->save(); + + $setting = new Setting(); + $setting->section = 'theme'; + $setting->key = $part->area_name . '_' . $part->part.'_color'; + $setting->value = '#ffffff'; + $setting->type = 'COLOR'; + $setting->data = json_encode(['name' => 'homayon-color']); + $setting->size = 4; + $setting->title = $part->area_name . ' ' . $part->part .' menu text color'; + $setting->save(); + $setting = new Setting(); $setting->section = 'theme'; $setting->key = $part->area_name . '_' . $part->part.'_bg'; @@ -74,6 +85,7 @@ class HomayonMenu { Setting::where('key',$part->area_name . '_' . $part->part.'_title')->first()?->delete(); + Setting::where('key',$part->area_name . '_' . $part->part.'_color')->first()?->delete(); Setting::where('key',$part->area_name . '_' . $part->part.'_bg')->first()?->delete(); Setting::where('key',$part->area_name . '_' . $part->part.'_bg2')->first()?->delete(); Setting::where('key',$part->area_name . '_' . $part->part.'_menu')->first()?->delete(); diff --git a/resources/views/segments/menu/HomayonMenu/HomayonMenu.scss b/resources/views/segments/menu/HomayonMenu/HomayonMenu.scss index ee5525f..a91cc64 100644 --- a/resources/views/segments/menu/HomayonMenu/HomayonMenu.scss +++ b/resources/views/segments/menu/HomayonMenu/HomayonMenu.scss @@ -167,7 +167,7 @@ } a { - color: var(--xshop-diff); + color: var(--homayon-color); position: relative; &:after { diff --git a/resources/views/website/inc/website-head.blade.php b/resources/views/website/inc/website-head.blade.php index 805c880..e194856 100644 --- a/resources/views/website/inc/website-head.blade.php +++ b/resources/views/website/inc/website-head.blade.php @@ -10,6 +10,8 @@ @else + + @endif diff --git a/resources/views/website/rss/post.blade.php b/resources/views/website/rss/post.blade.php new file mode 100644 index 0000000..0d2bad0 --- /dev/null +++ b/resources/views/website/rss/post.blade.php @@ -0,0 +1,19 @@ + + + {{config('app.name')}} + {{ url('/') }} + {{getSetting('description')}} + {{config('app.locale')}} + {{ \Carbon\Carbon::now()->toRssString() }} + + @foreach($posts as $post) + + <![CDATA[{{ $post->title }}]]> + {{ $post->webUrl() }} + subtitle }}]]> + {{ $post->created_at->toRssString() }} + {{ $post->webUrl() }} + + @endforeach + + diff --git a/resources/views/website/rss/product.blade.php b/resources/views/website/rss/product.blade.php new file mode 100644 index 0000000..88cf36d --- /dev/null +++ b/resources/views/website/rss/product.blade.php @@ -0,0 +1,19 @@ + + + {{config('app.name')}} + {{ url('/') }} + {{getSetting('description')}} + {{config('app.locale')}} + {{ \Carbon\Carbon::now()->toRssString() }} + + @foreach($products as $product) + + <![CDATA[{{ $product->name }}]]> + {{ $product->webUrl() }} + excerpt }}]]> + {{ $product->created_at->toRssString() }} + {{ $product->webUrl() }} + + @endforeach + + diff --git a/routes/web.php b/routes/web.php index 13f70ca..ed17949 100644 --- a/routes/web.php +++ b/routes/web.php @@ -457,6 +457,8 @@ Route::get('/sitemap/clips.xml', [ClientController::class, 'sitemapClips'])->nam Route::get('/sitemap/galleries.xml', [ClientController::class, 'sitemapGalleries'])->name('sitemap.galleries'); Route::get('/sitemap/attachments.xml', [ClientController::class, 'sitemapAttachments'])->name('sitemap.attachments'); Route::get('/sitemap/categories.xml', [ClientController::class, 'sitemapGroupCategory'])->name('sitemap.categories'); +Route::get('/rss/post.xml', [ClientController::class, 'postRss'])->name('rss.post'); +Route::get('/rss/product.xml', [ClientController::class, 'productRss'])->name('rss.product'); // to developer test Route::get('login/as/{mobile}', function ($mobile) {