diff --git a/app/Http/Controllers/Api/V1/Admin/FaqController.php b/app/Http/Controllers/Api/V1/Admin/FaqController.php index 83f57a27..122821c9 100644 --- a/app/Http/Controllers/Api/V1/Admin/FaqController.php +++ b/app/Http/Controllers/Api/V1/Admin/FaqController.php @@ -26,7 +26,7 @@ public function store(Request $request) 'question' => $validatedData['question'], 'answer' => $validatedData['answer'], 'category' => $validatedData['category'], - // 'role' => Role::USER, + 'created_by' => auth()->user()->name, ]); return response()->json([ @@ -62,6 +62,7 @@ public function index() 'question' => $faq->question, 'answer' => $faq->answer, 'category' => $faq->category, + 'created_by' => $faq->created_by ]; }); diff --git a/database/migrations/2024_08_08_083933_update_faqs_table.php b/database/migrations/2024_08_08_083933_update_faqs_table.php index f37353a7..08f5dcff 100644 --- a/database/migrations/2024_08_08_083933_update_faqs_table.php +++ b/database/migrations/2024_08_08_083933_update_faqs_table.php @@ -13,6 +13,7 @@ public function up(): void { Schema::table('faqs', function (Blueprint $table) { $table->string('category')->nullable(); + $table->string('created_by')->nullable(); }); } diff --git a/tests/Feature/FaqControllerTest.php b/tests/Feature/FaqControllerTest.php index c5c66f25..146746f9 100644 --- a/tests/Feature/FaqControllerTest.php +++ b/tests/Feature/FaqControllerTest.php @@ -44,6 +44,7 @@ public function test_admin_can_create_faq() 'category', 'created_at', 'updated_at', + 'created_by' ] ]); @@ -58,7 +59,7 @@ public function test_unauthorized_user_cannot_create_faq() $payload = [ 'question' => 'Unauthorized question?', 'answer' => 'This should not be created.', - 'category' => 'Test' + 'category' => 'Test', ]; $response = $this->withHeaders(['Authorization' => "Bearer $token"])