phase 4
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
return ['name' => 'Feeds'];
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
namespace Modules\Feeds\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Response; use Modules\Blog\Models\Blog; use Modules\News\Models\News;
|
||||
final class FeedController extends Controller { public function blog(): Response { return response()->view('feeds::rss',['title'=>config('app.name').' Blog','records'=>Blog::published()->latest('published_at')->limit(50)->get(),'routeName'=>'blog.public.show'])->header('Content-Type','application/rss+xml; charset=UTF-8'); } public function news(): Response { return response()->view('feeds::rss',['title'=>config('app.name').' News','records'=>News::published()->latest('published_at')->limit(50)->get(),'routeName'=>'news.public.show'])->header('Content-Type','application/rss+xml; charset=UTF-8'); } }
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Modules\Feeds\Providers;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
final class FeedsServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
$this->mergeConfigFrom(module_path('Feeds', 'Config/config.php'), 'feeds');
|
||||
}
|
||||
public function boot(): void
|
||||
{
|
||||
$this->loadMigrationsFrom(module_path('Feeds', 'Database/Migrations'));
|
||||
$this->loadViewsFrom(module_path('Feeds', 'Resources/views'), 'feeds');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace Modules\Feeds\Providers;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
final class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
Route::middleware('web')->group(module_path('Feeds', 'Routes/web.php'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{!! '<?xml version="1.0" encoding="UTF-8"?>' !!}<rss version="2.0"><channel><title>{{ $title }}</title><link>{{ url('/') }}</link><description>{{ $title }}</description>@foreach($records as $record)<item><title>{{ $record->title }}</title><link>{{ route($routeName, $record->slug) }}</link><guid>{{ route($routeName, $record->slug) }}</guid><description><![CDATA[{{ $record->excerpt }}]]></description><pubDate>{{ optional($record->published_at)->toRssString() }}</pubDate></item>@endforeach</channel></rss>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Support\Facades\Route; use Modules\Feeds\Http\Controllers\FeedController;
|
||||
Route::get('/feeds/blog.xml',[FeedController::class,'blog'])->name('feeds.blog'); Route::get('/feeds/news.xml',[FeedController::class,'news'])->name('feeds.news');
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Modules\Feeds\Tests\Feature;
|
||||
use Tests\TestCase;
|
||||
final class ModuleBootTest extends TestCase
|
||||
{
|
||||
public function test_module_configuration_is_available(): void
|
||||
{
|
||||
$this->assertSame('Feeds', config('feeds.name'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "Feeds",
|
||||
"alias": "feeds",
|
||||
"version": "1.0.0",
|
||||
"description": "Feeds publishing module.",
|
||||
"keywords": ["publishing", "feeds"],
|
||||
"priority": 30,
|
||||
"providers": ["Modules\\Feeds\\Providers\\FeedsServiceProvider"],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": ["Core", "Administration"]
|
||||
}
|
||||
Reference in New Issue
Block a user