@@ -1,19 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\EvidenceSubmission;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EvidenceSubmissionController extends Controller
|
||||
{
|
||||
public function create() { return view('pages.submit-evidence'); }
|
||||
public function create()
|
||||
{
|
||||
return view('pages.submit-evidence');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name'=>'nullable|string|max:120','email'=>'nullable|email|max:255','park_name'=>'nullable|string|max:180',
|
||||
'operator'=>'nullable|string|max:180','purchase_price'=>'nullable|numeric|min:0|max:10000000','valuation'=>'nullable|numeric|min:0|max:10000000',
|
||||
'finance_balance'=>'nullable|numeric|min:0|max:10000000','story'=>'required|string|min:20|max:10000','consent_to_contact'=>'nullable|boolean',
|
||||
'name' => 'nullable|string|max:120', 'email' => 'nullable|email|max:255', 'park_name' => 'nullable|string|max:180',
|
||||
'operator' => 'nullable|string|max:180', 'purchase_price' => 'nullable|numeric|min:0|max:10000000', 'valuation' => 'nullable|numeric|min:0|max:10000000',
|
||||
'finance_balance' => 'nullable|numeric|min:0|max:10000000', 'story' => 'required|string|min:20|max:10000', 'consent_to_contact' => 'nullable|boolean',
|
||||
]);
|
||||
$data['consent_to_contact'] = $request->boolean('consent_to_contact');
|
||||
EvidenceSubmission::create($data);
|
||||
|
||||
return redirect()->route('evidence.create')->with('status', 'Thank you. Your evidence has been submitted for review.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EvidenceSubmission extends Model
|
||||
{
|
||||
protected $fillable = ['name','email','park_name','operator','purchase_price','valuation','finance_balance','story','consent_to_contact'];
|
||||
protected $casts = ['consent_to_contact'=>'boolean','purchase_price'=>'decimal:2','valuation'=>'decimal:2','finance_balance'=>'decimal:2'];
|
||||
protected $fillable = ['name', 'email', 'park_name', 'operator', 'purchase_price', 'valuation', 'finance_balance', 'story', 'consent_to_contact'];
|
||||
|
||||
protected $casts = ['consent_to_contact' => 'boolean', 'purchase_price' => 'decimal:2', 'valuation' => 'decimal:2', 'finance_balance' => 'decimal:2'];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration { public function up(): void { Schema::create('evidence_submissions', function (Blueprint $table) { $table->id(); $table->string('name')->nullable(); $table->string('email')->nullable(); $table->string('park_name')->nullable(); $table->string('operator')->nullable(); $table->decimal('purchase_price',12,2)->nullable(); $table->decimal('valuation',12,2)->nullable(); $table->decimal('finance_balance',12,2)->nullable(); $table->text('story'); $table->boolean('consent_to_contact')->default(false); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('evidence_submissions'); } };
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('evidence_submissions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('park_name')->nullable();
|
||||
$table->string('operator')->nullable();
|
||||
$table->decimal('purchase_price', 12, 2)->nullable();
|
||||
$table->decimal('valuation', 12, 2)->nullable();
|
||||
$table->decimal('finance_balance', 12, 2)->nullable();
|
||||
$table->text('story');
|
||||
$table->boolean('consent_to_contact')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('evidence_submissions');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user