added rss feed to project

master
A1Gard 7 days ago
parent 9d2c7a1dae
commit 6e478ce10f

@ -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 = '<?xml version="1.0" encoding="UTF-8" ?>' . 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 = '<?xml version="1.0" encoding="UTF-8" ?>' . 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');
}
}

@ -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": "*",

@ -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),
/*
|--------------------------------------------------------------------------

@ -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();

@ -167,7 +167,7 @@
}
a {
color: var(--xshop-diff);
color: var(--homayon-color);
position: relative;
&:after {

@ -10,6 +10,8 @@
<meta name="robots" content="noindex">
@else
<meta name="robots" content="follow,index">
<link rel="alternate" type="application/rss+xml" title="{{__("Post RSS Feed")}}" href="{{route('rss.post')}}" />
<link rel="alternate" type="application/rss+xml" title="{{__("Product RSS Feed")}}" href="{{route('rss.product')}}" />
@endif
<meta name="generator" content="xShop; version={{config('app.version')}}">

@ -0,0 +1,19 @@
<rss version="2.0">
<channel>
<title>{{config('app.name')}}</title>
<link>{{ url('/') }}</link>
<description>{{getSetting('description')}}</description>
<language>{{config('app.locale')}}</language>
<pubDate>{{ \Carbon\Carbon::now()->toRssString() }}</pubDate>
@foreach($posts as $post)
<item>
<title><![CDATA[{{ $post->title }}]]></title>
<link>{{ $post->webUrl() }}</link>
<description><![CDATA[{{ $post->subtitle }}]]></description>
<pubDate>{{ $post->created_at->toRssString() }}</pubDate>
<guid>{{ $post->webUrl() }}</guid>
</item>
@endforeach
</channel>
</rss>

@ -0,0 +1,19 @@
<rss version="2.0">
<channel>
<title>{{config('app.name')}}</title>
<link>{{ url('/') }}</link>
<description>{{getSetting('description')}}</description>
<language>{{config('app.locale')}}</language>
<pubDate>{{ \Carbon\Carbon::now()->toRssString() }}</pubDate>
@foreach($products as $product)
<item>
<title><![CDATA[{{ $product->name }}]]></title>
<link>{{ $product->webUrl() }}</link>
<description><![CDATA[{{ $product->excerpt }}]]></description>
<pubDate>{{ $product->created_at->toRssString() }}</pubDate>
<guid>{{ $product->webUrl() }}</guid>
</item>
@endforeach
</channel>
</rss>

@ -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) {

Loading…
Cancel
Save