diff --git a/app/Http/Controllers/Api/V1/SqueezePageCoontroller.php b/app/Http/Controllers/Api/V1/SqueezePageCoontroller.php new file mode 100644 index 00000000..b47b9274 --- /dev/null +++ b/app/Http/Controllers/Api/V1/SqueezePageCoontroller.php @@ -0,0 +1,79 @@ +get(); + return response()->json([ + 'status' => Response::HTTP_OK, + 'message' => 'Squeeze Pages retrieved successfully', + 'data' => $plans, + ]); + } catch (\Exception $e) { + return response()->json([ + 'message' => 'Internal server error', + 'status' => Response::HTTP_INTERNAL_SERVER_ERROR + ], Response::HTTP_INTERNAL_SERVER_ERROR); + } + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Models/SqueezePage.php b/app/Models/SqueezePage.php index 62df2463..6b84da3f 100644 --- a/app/Models/SqueezePage.php +++ b/app/Models/SqueezePage.php @@ -9,4 +9,18 @@ class SqueezePage extends Model { use HasFactory, HasUuids; + + + protected $fillable = [ + 'title', + 'slug', + 'status', + 'activate', + 'headline', + 'sub_headline', + 'hero_image', + 'content', + ]; + + } diff --git a/database/migrations/2024_08_07_063753_add_columns_to_squeeze_pages_table.php b/database/migrations/2024_08_07_063753_add_columns_to_squeeze_pages_table.php new file mode 100644 index 00000000..fe00a5d6 --- /dev/null +++ b/database/migrations/2024_08_07_063753_add_columns_to_squeeze_pages_table.php @@ -0,0 +1,34 @@ +string('title'); + $table->string('slug')->unique(); + $table->enum('status', ['offline', 'online'])->default('online'); + $table->boolean('activate'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('squeeze_pages', function (Blueprint $table) { + $table->dropColumn('title'); + $table->dropColumn('slug'); + $table->dropColumn('status'); + $table->dropColumn('activate'); + }); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 93c398eb..cb17e532 100755 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -76,7 +76,8 @@ public function run(): void FaqSeeder::class, UserNotificationSeeder::class, NotificationSettingSeeder::class, - OrderSeeder::class + OrderSeeder::class, + SqueezePageSeeder::class ]); } diff --git a/database/seeders/SqueezePageSeeder.php b/database/seeders/SqueezePageSeeder.php index 5e671b8f..69ad4411 100644 --- a/database/seeders/SqueezePageSeeder.php +++ b/database/seeders/SqueezePageSeeder.php @@ -2,6 +2,7 @@ namespace Database\Seeders; +use App\Models\SqueezePage; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; @@ -12,6 +13,61 @@ class SqueezePageSeeder extends Seeder */ public function run(): void { - // + $squeezePages = [ + [ + 'title' => 'Digital Marketing', + 'slug' => 'digital-marketing', + 'status' => 'online', + 'activate' => true, + 'headline' => 'Master Digital Marketing', + 'sub_headline' => 'Unlock the Secrets of Online Success', + 'hero_image' => 'digital_marketing.jpg', + 'content' => 'Learn the best strategies to excel in digital marketing...', + ], + [ + 'title' => 'Conversion Secrets', + 'slug' => 'conversion-secrets', + 'status' => 'online', + 'activate' => true, + 'headline' => 'Increase Your Conversions', + 'sub_headline' => 'Discover Proven Techniques', + 'hero_image' => 'conversion_secrets.jpg', + 'content' => 'Find out how to turn visitors into customers...', + ], + [ + 'title' => 'Email Mastery', + 'slug' => 'email-mastery', + 'status' => 'offline', + 'activate' => false, + 'headline' => 'Master Email Marketing', + 'sub_headline' => 'Boost Your Campaigns', + 'hero_image' => 'email_mastery.jpg', + 'content' => 'Effective email marketing strategies to engage your audience...', + ], + [ + 'title' => 'Social Growth', + 'slug' => 'social-growth', + 'status' => 'offline', + 'activate' => false, + 'headline' => 'Grow Your Social Media', + 'sub_headline' => 'Strategies for Success', + 'hero_image' => 'social_growth.jpg', + 'content' => 'Learn how to grow your social media presence...', + ], + [ + 'title' => 'Content Blueprint', + 'slug' => 'content-blueprint', + 'status' => 'online', + 'activate' => true, + 'headline' => 'Content Marketing Blueprint', + 'sub_headline' => 'Your Guide to Success', + 'hero_image' => 'content_blueprint.jpg', + 'content' => 'Step-by-step guide to successful content marketing...', + ], + ]; + + foreach ($squeezePages as $squeezePage) { + SqueezePage::create($squeezePage); + } } } diff --git a/routes/api.php b/routes/api.php index f5bbb0c9..66138f1b 100755 --- a/routes/api.php +++ b/routes/api.php @@ -42,8 +42,7 @@ use App\Http\Controllers\Api\V1\JobSearchController; use App\Http\Controllers\Api\V1\WaitListController; use App\Http\Controllers\Api\V1\CookiePreferencesController; - - +use App\Http\Controllers\Api\V1\SqueezePageCoontroller; /* |-------------------------------------------------------------------------- @@ -129,7 +128,6 @@ Route::get('/cookies/preferences', [CookiePreferencesController::class, 'getPreferences']); - // Help Articles Route::post('/help-center/topics', [HelpArticleController::class, 'store']); Route::patch('/help-center/topics/{articleId}', [HelpArticleController::class, 'update']); @@ -220,13 +218,9 @@ Route::patch('/blogs/edit/{id}', [BlogController::class, 'update'])->name('admin.blogs.update'); Route::delete('/blogs/{id}', [BlogController::class, 'destroy']); Route::get('/waitlists', [WaitListController::class, 'index']); + Route::apiResource('squeeze-pages', SqueezePageCoontroller::class); }); - - - - - Route::post('/waitlists', [WaitListController::class, 'store']); Route::apiResource('faqs', FaqController::class); diff --git a/tests/Feature/SqueezePagesTest.php b/tests/Feature/SqueezePagesTest.php new file mode 100644 index 00000000..9b778e69 --- /dev/null +++ b/tests/Feature/SqueezePagesTest.php @@ -0,0 +1,55 @@ +adminUser = User::factory()->create(['role' => 'admin']); + $this->adminToken = JWTAuth::fromUser($this->adminUser); + } + + + public function test_it_retrieves_squeeze_pages_successfully() + { + $response = $this->withHeaders(['Authorization' => "Bearer $this->adminToken"]) + ->getJson('/api/v1/squeeze-pages'); + + $response->assertStatus(200) + ->assertJsonStructure([ + 'status', + 'message', + 'data' => [ + '*' => [ + 'id', + 'title', + 'slug', + 'created_at', + 'status', + 'activate', + ] + ] + ]); + } + + public function test_if_it_fails_for_unathorised_access_to_squeeze_pages() + { + + $response = $this->getJson('/api/v1/squeeze-pages'); + $response->assertStatus(401); + } +}