Implement news management features: add author field and comments functionality in NewsResource, enhance HomePageController to fetch latest news, and create dedicated views for news display and commenting. Update routes for comment submission and adjust homepage to showcase recent news articles.

This commit is contained in:
2025-07-28 18:56:17 +05:00
parent 189cb53856
commit 74fc3b5e6a
22 changed files with 513 additions and 58 deletions

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('news', function (Blueprint $table) {
$table->string('author')->after('image')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('news', function (Blueprint $table) {
$table->dropColumn('author');
});
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('comments', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('message');
$table->string('author_name')->nullable();
$table->foreignId('news_id')->constrained()->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('comments');
}
};

View File

@@ -0,0 +1,14 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('cta.title', 'Join Our Community and Access Exclusive Insights Today');
$this->migrator->add('cta.button_text', 'Free Consultation');
$this->migrator->add('cta.button_url', 'request-quote.html');
$this->migrator->add('cta.background_image', '');
}
};

View File

@@ -13,6 +13,8 @@ class NewsTableSeeder extends Seeder
*/
public function run(): void
{
News::factory()->count(12)->create();
News::factory()->count(12)->create([
'image' => '/web/assets/img/page/breadcrumb.jpg',
]);
}
}