add create/edit functionality
This commit is contained in:
parent
d5770b8cb5
commit
73ba1c8fed
@ -2,23 +2,25 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Device;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\LocationTransaction;
|
use App\Models\LocationTransaction;
|
||||||
|
|
||||||
class LocationTransactionController extends Controller
|
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([
|
$formFields = $request->validate([
|
||||||
'room_code' => 'required',
|
'room_code' => 'required',
|
||||||
'timestamp_located_since' => 'required'
|
'timestamp_located_since' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$formFields['device_id'] = $device->device_id;
|
||||||
LocationTransaction::create($formFields);
|
LocationTransaction::create($formFields);
|
||||||
|
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
@ -38,7 +40,7 @@ public function update(LocationTransaction $location, Request $request)
|
|||||||
|
|
||||||
$location->update($formFields);
|
$location->update($formFields);
|
||||||
|
|
||||||
return back();
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(LocationTransaction $location)
|
public function destroy(LocationTransaction $location)
|
||||||
|
@ -2,23 +2,25 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Device;
|
||||||
use App\Models\OwnerTransaction;
|
use App\Models\OwnerTransaction;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class OwnerTransactionController extends Controller
|
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([
|
$formFields = $request->validate([
|
||||||
'rz_username' => 'required',
|
'rz_username' => 'required',
|
||||||
'timestamp_owner_since' => 'required'
|
'timestamp_owner_since' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$formFields['device_id'] = $device->device_id;
|
||||||
OwnerTransaction::create($formFields);
|
OwnerTransaction::create($formFields);
|
||||||
|
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
@ -38,7 +40,7 @@ public function update(OwnerTransaction $owner, Request $request)
|
|||||||
|
|
||||||
$owner->update($formFields);
|
$owner->update($formFields);
|
||||||
|
|
||||||
return back();
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(OwnerTransaction $owner)
|
public function destroy(OwnerTransaction $owner)
|
||||||
|
@ -23,12 +23,12 @@
|
|||||||
$ownerTransactins = $device->owners;
|
$ownerTransactins = $device->owners;
|
||||||
@endphp
|
@endphp
|
||||||
<h3>Location Transactions</h3>
|
<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)
|
@foreach ($locationTransactions as $location)
|
||||||
<x-location-transaction :location="$location" />
|
<x-location-transaction :location="$location" />
|
||||||
@endforeach
|
@endforeach
|
||||||
<h3>Owner Transactions</h3>
|
<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)
|
@foreach ($ownerTransactins as $owner)
|
||||||
<x-owner-transaction :owner="$owner" />
|
<x-owner-transaction :owner="$owner" />
|
||||||
@endforeach
|
@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">
|
<form method="POST" action="/devices/{{ $purchasing->device->device_id }}/purchasing">
|
||||||
@method('PUT')
|
@method('PUT')
|
||||||
@csrf
|
@csrf
|
||||||
|
Loading…
Reference in New Issue
Block a user