diff --git a/ChatGPT/HTML Form b/ChatGPT/HTML Form new file mode 100644 index 0000000..bd90abf --- /dev/null +++ b/ChatGPT/HTML Form @@ -0,0 +1,35 @@ +please generate me a form in html with 8 different inputs + +Certainly! Here's an example of an HTML form with 8 different inputs: + +html + +
+ +This form includes 8 different inputs: a name field, an email field, a phone field, an address field, a city field, a state field, a zip code field, and a message field. Each input has a label associated with it for accessibility purposes, and the form includes a submit button to submit the user's input. Note that the "required" attribute has been added to each input to require the user to fill out all the fields before submitting the form. diff --git a/README.md b/README.md index 7b43cde..eba681c 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,13 @@ latest: 15.04.2023 ## About Laravel is a full feature framework +### security +coss-side-scripting disabled + ## Database setup ### Data seed -sail exec laravel.test php artisan migrate:refresh --seed \ No newline at end of file +sail exec laravel.test php artisan migrate:refresh --seed + +## ChatGPT +see ChatGPT folder \ No newline at end of file diff --git a/device-app/app/Http/Controllers/DeviceController.php b/device-app/app/Http/Controllers/DeviceController.php index e3a5f8a..2a299f2 100644 --- a/device-app/app/Http/Controllers/DeviceController.php +++ b/device-app/app/Http/Controllers/DeviceController.php @@ -4,6 +4,7 @@ use App\Models\Device; use Illuminate\Http\Request; +use Illuminate\Validation\Rule; class DeviceController extends Controller { @@ -16,9 +17,24 @@ public function index() } public function create(){ - return view('devices.create', [ + return view('devices.create'); + } + public function store(Request $request){ + $formFields = $request->validate([ + 'device_id' => ['required', Rule::unique('devices', 'device_id')], + 'title' => 'required', + 'device_type' => 'required', + 'description' => 'required', + 'accessories' => 'required', + 'rz_username_buyer' => ['required', Rule::unique('devices', 'device_id')], + 'serial_number' => 'required', + 'image_url' => 'required', ]); + + Device::create($formFields); + + return redirect('/devices'); } public function show(Device $device) diff --git a/device-app/app/Models/Device.php b/device-app/app/Models/Device.php index 8293e27..627f121 100644 --- a/device-app/app/Models/Device.php +++ b/device-app/app/Models/Device.php @@ -17,5 +17,8 @@ class Device extends Model * @var string */ protected $primaryKey = 'device_id'; + + protected $fillable = ['device_id', 'title', 'device_type', 'description', 'accessories', 'rz_username_buyer', 'serial_number', 'image_url']; + use HasFactory; } \ No newline at end of file diff --git a/device-app/resources/views/devices/create.blade.php b/device-app/resources/views/devices/create.blade.php index f7c898f..83a362f 100644 --- a/device-app/resources/views/devices/create.blade.php +++ b/device-app/resources/views/devices/create.blade.php @@ -1,5 +1,56 @@ @extends('layout') @section('content') -create + @endsection \ No newline at end of file diff --git a/device-app/routes/web.php b/device-app/routes/web.php index fcb2b37..905daee 100644 --- a/device-app/routes/web.php +++ b/device-app/routes/web.php @@ -24,7 +24,10 @@ // create - show create form Route::get('/devices/create', [DeviceController::class, 'create']); + // store - store new device +Route::post('/devices', [DeviceController::class, 'store']); + // edit - show edit form // update - update device // destroy - delete device