add basic device create process
This commit is contained in:
parent
ab5181068d
commit
2524bcc41e
35
ChatGPT/HTML Form
Normal file
35
ChatGPT/HTML Form
Normal file
@ -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
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<label for="name">Name:</label>
|
||||||
|
<input type="text" id="name" name="name" required>
|
||||||
|
|
||||||
|
<label for="email">Email:</label>
|
||||||
|
<input type="email" id="email" name="email" required>
|
||||||
|
|
||||||
|
<label for="phone">Phone:</label>
|
||||||
|
<input type="tel" id="phone" name="phone" required>
|
||||||
|
|
||||||
|
<label for="address">Address:</label>
|
||||||
|
<input type="text" id="address" name="address" required>
|
||||||
|
|
||||||
|
<label for="city">City:</label>
|
||||||
|
<input type="text" id="city" name="city" required>
|
||||||
|
|
||||||
|
<label for="state">State:</label>
|
||||||
|
<input type="text" id="state" name="state" required>
|
||||||
|
|
||||||
|
<label for="zip">Zip Code:</label>
|
||||||
|
<input type="text" id="zip" name="zip" required>
|
||||||
|
|
||||||
|
<label for="message">Message:</label>
|
||||||
|
<textarea id="message" name="message"></textarea>
|
||||||
|
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
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.
|
@ -25,7 +25,13 @@ latest: 15.04.2023
|
|||||||
## About
|
## About
|
||||||
Laravel is a full feature framework
|
Laravel is a full feature framework
|
||||||
|
|
||||||
|
### security
|
||||||
|
coss-side-scripting disabled
|
||||||
|
|
||||||
## Database setup
|
## Database setup
|
||||||
|
|
||||||
### Data seed
|
### Data seed
|
||||||
sail exec laravel.test php artisan migrate:refresh --seed
|
sail exec laravel.test php artisan migrate:refresh --seed
|
||||||
|
|
||||||
|
## ChatGPT
|
||||||
|
see ChatGPT folder
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class DeviceController extends Controller
|
class DeviceController extends Controller
|
||||||
{
|
{
|
||||||
@ -16,9 +17,24 @@ public function index()
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function create(){
|
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)
|
public function show(Device $device)
|
||||||
|
@ -17,5 +17,8 @@ class Device extends Model
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $primaryKey = 'device_id';
|
protected $primaryKey = 'device_id';
|
||||||
|
|
||||||
|
protected $fillable = ['device_id', 'title', 'device_type', 'description', 'accessories', 'rz_username_buyer', 'serial_number', 'image_url'];
|
||||||
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
}
|
}
|
@ -1,5 +1,56 @@
|
|||||||
@extends('layout')
|
@extends('layout')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
create
|
<form method="POST" action="/devices">
|
||||||
|
@csrf
|
||||||
|
<label for="device_id">device_id:</label>
|
||||||
|
<input type="text" id="device_id" name="device_id" required>
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<label for="title">Title:</label>
|
||||||
|
<input type="text" id="title" name="title" required>
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<label for="device_type">device_type:</label>
|
||||||
|
<input type="text" id="device_type" name="device_type" required>
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<label for="accessories">accessories:</label>
|
||||||
|
<input type="text" id="accessories" name="accessories">
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<label for="rz_username_buyer">rz_username_buyer:</label>
|
||||||
|
<input type="text" id="rz_username_buyer" name="rz_username_buyer" required>
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<label for="serial_number">serial_number:</label>
|
||||||
|
<input type="text" id="serial_number" name="serial_number" required>
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<label for="image_url">image_url:</label>
|
||||||
|
<input id="image_url" name="image_url" required>
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<label for="description">description:</label>
|
||||||
|
<textarea type="text" id="description" name="description"></textarea>
|
||||||
|
@error('device_id')
|
||||||
|
<p>{{$message}}</p>
|
||||||
|
@enderror
|
||||||
|
<br />
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
@endsection
|
@endsection
|
@ -24,7 +24,10 @@
|
|||||||
|
|
||||||
// create - show create form
|
// create - show create form
|
||||||
Route::get('/devices/create', [DeviceController::class, 'create']);
|
Route::get('/devices/create', [DeviceController::class, 'create']);
|
||||||
|
|
||||||
// store - store new device
|
// store - store new device
|
||||||
|
Route::post('/devices', [DeviceController::class, 'store']);
|
||||||
|
|
||||||
// edit - show edit form
|
// edit - show edit form
|
||||||
// update - update device
|
// update - update device
|
||||||
// destroy - delete device
|
// destroy - delete device
|
||||||
|
Loading…
Reference in New Issue
Block a user