diff --git a/app/Http/Requests/Quotation/AddQuotationRequest.php b/app/Http/Requests/Quotation/AddQuotationRequest.php index ce9cad9..8309954 100644 --- a/app/Http/Requests/Quotation/AddQuotationRequest.php +++ b/app/Http/Requests/Quotation/AddQuotationRequest.php @@ -14,7 +14,7 @@ public function rules(): array 'phone' => 'required|numeric', 'email' => 'required|email', 'message' => 'required|string', - 'attachment' => 'required|file|mimes:pdf,doc,docx,txt', + 'attachment' => 'nullable|file', ]; } } diff --git a/app/Services/QuotationService.php b/app/Services/QuotationService.php index 8516f08..93c4ad2 100644 --- a/app/Services/QuotationService.php +++ b/app/Services/QuotationService.php @@ -19,14 +19,27 @@ public function __construct() public function create($data) { - $attachment = ImageService::upload_image($data['attachment'], "Quotation"); + + if (isset($data['attachment']) && !empty($data['attachment'])) { + + $attachment = ImageService::upload_image($data['attachment'], "Quotation"); + parent::create([ + 'name' => $data['name'], + 'phone' => $data['phone'], + 'email' => $data['email'], + 'message' => $data['message'], + 'attachment' => $attachment + ]); + + return true ; + } parent::create([ 'name' => $data['name'], 'phone' => $data['phone'], 'email' => $data['email'], 'message' => $data['message'], - 'attachment' => $attachment + ]); return true; diff --git a/database/migrations/2024_03_31_072859_create_quotations_table.php b/database/migrations/2024_03_31_072859_create_quotations_table.php index 09f4509..61daf4c 100644 --- a/database/migrations/2024_03_31_072859_create_quotations_table.php +++ b/database/migrations/2024_03_31_072859_create_quotations_table.php @@ -17,7 +17,7 @@ public function up(): void $table->string('phone'); $table->string('email'); $table->text('message'); - $table->string('attachment'); + $table->string('attachment')->nullable(); $table->timestamps(); }); } diff --git a/database/seeders/KeysSeeder.php b/database/seeders/KeysSeeder.php index d57b8a4..10f8041 100644 --- a/database/seeders/KeysSeeder.php +++ b/database/seeders/KeysSeeder.php @@ -20,8 +20,13 @@ public function run(): void 'value' => 'Home page description', 'type' => 'home', ], + // [ + // 'key' => 'home_main_image', + // 'value' => '/', + // 'type' => 'home', + // ], [ - 'key' => 'home_main_image', + 'key' => 'portfolio', 'value' => '/', 'type' => 'home', ], @@ -45,6 +50,21 @@ public function run(): void 'value' => "links", 'type' => 'setting', ], + [ + 'key' => 'links', + 'value' => "links", + 'type' => 'setting', + ], + [ + 'key' => 'facebook', + 'value' => "facebook", + 'type' => 'setting', + ], + [ + 'key' => 'linkedin', + 'value' => "linkedin", + 'type' => 'setting', + ], ]; foreach ($keys as $key) {