add create/edit functionality
This commit is contained in:
parent
d5770b8cb5
commit
73ba1c8fed
@ -2,23 +2,25 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Device;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\LocationTransaction;
|
||||
|
||||
class LocationTransactionController extends Controller
|
||||
{
|
||||
public function create()
|
||||
public function create(Device $device)
|
||||
{
|
||||
return view('locations.create');
|
||||
return view('locations.create', ['device' => $device]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
public function store(Device $device, Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'room_code' => 'required',
|
||||
'timestamp_located_since' => 'required'
|
||||
]);
|
||||
|
||||
$formFields['device_id'] = $device->device_id;
|
||||
LocationTransaction::create($formFields);
|
||||
|
||||
return redirect('/');
|
||||
@ -38,7 +40,7 @@ public function update(LocationTransaction $location, Request $request)
|
||||
|
||||
$location->update($formFields);
|
||||
|
||||
return back();
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function destroy(LocationTransaction $location)
|
||||
|
@ -2,23 +2,25 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\OwnerTransaction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OwnerTransactionController extends Controller
|
||||
{
|
||||
public function create()
|
||||
public function create(Device $device)
|
||||
{
|
||||
return view('owners.create');
|
||||
return view('owners.create', ['device' => $device]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
public function store(Device $device, Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'rz_username' => 'required',
|
||||
'timestamp_owner_since' => 'required'
|
||||
]);
|
||||
|
||||
$formFields['device_id'] = $device->device_id;
|
||||
OwnerTransaction::create($formFields);
|
||||
|
||||
return redirect('/');
|
||||
@ -38,7 +40,7 @@ public function update(OwnerTransaction $owner, Request $request)
|
||||
|
||||
$owner->update($formFields);
|
||||
|
||||
return back();
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function destroy(OwnerTransaction $owner)
|
||||
|
@ -23,12 +23,12 @@
|
||||
$ownerTransactins = $device->owners;
|
||||
@endphp
|
||||
<h3>Location Transactions</h3>
|
||||
<button><a href="{{ $device->device_id }}/location/create">New Location</a></button>
|
||||
<button><a href="{{ $device->device_id }}/locations/create">New Location</a></button>
|
||||
@foreach ($locationTransactions as $location)
|
||||
<x-location-transaction :location="$location" />
|
||||
@endforeach
|
||||
<h3>Owner Transactions</h3>
|
||||
<button><a href="{{ $device->device_id }}/owner/create">New Owner</a></button>
|
||||
<button><a href="{{ $device->device_id }}/owners/create">New Owner</a></button>
|
||||
@foreach ($ownerTransactins as $owner)
|
||||
<x-owner-transaction :owner="$owner" />
|
||||
@endforeach
|
||||
|
17
device-app/resources/views/locations/create.blade.php
Normal file
17
device-app/resources/views/locations/create.blade.php
Normal file
@ -0,0 +1,17 @@
|
||||
<form method="POST" action="/devices/{{ $device->device_id }}/locations">
|
||||
@csrf
|
||||
<label for="room_code">room_code:</label>
|
||||
<input type="text" id="room_code" name="room_code" value="{{old('room_code')}}" required>
|
||||
@error('room_code')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<label for="timestamp_located_since">timestamp_located_since:</label>
|
||||
<input type="text" id="timestamp_located_since" name="timestamp_located_since"
|
||||
value="{{old('timestamp_located_since')}}" required>
|
||||
@error('timestamp_located_since')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
18
device-app/resources/views/locations/edit.blade.php
Normal file
18
device-app/resources/views/locations/edit.blade.php
Normal file
@ -0,0 +1,18 @@
|
||||
<form method="POST" action="/devices/locations/{{ $location->location_transaction_id }}">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
<label for="room_code">room_code:</label>
|
||||
<input type="text" id="room_code" name="room_code" value="{{$location->room_code}}" required>
|
||||
@error('room_code')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<label for="timestamp_located_since">timestamp_located_since:</label>
|
||||
<input type="text" id="timestamp_located_since" name="timestamp_located_since"
|
||||
value="{{$location->timestamp_located_since}}" required>
|
||||
@error('timestamp_located_since')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
17
device-app/resources/views/owners/create.blade.php
Normal file
17
device-app/resources/views/owners/create.blade.php
Normal file
@ -0,0 +1,17 @@
|
||||
<form method="POST" action="/devices/{{ $device->device_id }}/owners">
|
||||
@csrf
|
||||
<label for="rz_username">rz_username:</label>
|
||||
<input type="text" id="rz_username" name="rz_username" value="{{old('rz_username')}}" required>
|
||||
@error('rz_username')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<label for="timestamp_owner_since">timestamp_owner_since:</label>
|
||||
<input type="text" id="timestamp_owner_since" name="timestamp_owner_since"
|
||||
value="{{old('timestamp_owner_since')}}" required>
|
||||
@error('timestamp_owner_since')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
18
device-app/resources/views/owners/edit.blade.php
Normal file
18
device-app/resources/views/owners/edit.blade.php
Normal file
@ -0,0 +1,18 @@
|
||||
<form method="POST" action="/devices/owners/{{ $owner->owner_transaction_id }}">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
<label for="rz_username">rz_username:</label>
|
||||
<input type="text" id="rz_username" name="rz_username" value="{{$owner->rz_username}}" required>
|
||||
@error('rz_username')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<label for="timestamp_owner_since">timestamp_owner_since:</label>
|
||||
<input type="text" id="timestamp_owner_since" name="timestamp_owner_since"
|
||||
value="{{$owner->timestamp_owner_since}}" required>
|
||||
@error('timestamp_owner_since')
|
||||
<p>{{ $message }}</p>
|
||||
@enderror
|
||||
<br />
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
@ -1,4 +1,3 @@
|
||||
<p>{{ $purchasing->price }}</p>
|
||||
<form method="POST" action="/devices/{{ $purchasing->device->device_id }}/purchasing">
|
||||
@method('PUT')
|
||||
@csrf
|
||||
|
Loading…
Reference in New Issue
Block a user