add components button
This commit is contained in:
parent
6894c2c3c5
commit
0e1de41203
@ -22,7 +22,6 @@ public function create(){
|
||||
|
||||
public function store(Request $request){
|
||||
$formFields = $request->validate([
|
||||
//'device_id' => ['required', Rule::unique('devices', 'device_id')],
|
||||
'title' => 'required',
|
||||
'device_type' => 'required',
|
||||
'description' => 'required',
|
||||
@ -43,7 +42,6 @@ public function edit(Device $device) {
|
||||
|
||||
public function update(Device $device, Request $request){
|
||||
$formFields = $request->validate([
|
||||
//'device_id' => 'required',
|
||||
'title' => 'required',
|
||||
'device_type' => 'required',
|
||||
'description' => 'required',
|
||||
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\LocationTransaction;
|
||||
|
||||
class LocationTransactionController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('locations.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'room_code' => 'required',
|
||||
'timestamp_located_since' => 'required'
|
||||
]);
|
||||
|
||||
LocationTransaction::create($formFields);
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function edit(LocationTransaction $location)
|
||||
{
|
||||
return view('locations.edit', ['location' => $location]);
|
||||
}
|
||||
|
||||
public function update(LocationTransaction $location, Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'room_code' => 'required',
|
||||
'timestamp_located_since' => 'required'
|
||||
]);
|
||||
|
||||
$location->update($formFields);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function destroy(LocationTransaction $location)
|
||||
{
|
||||
$location->delete();
|
||||
return back();
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\OwnerTransaction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OwnerTransactionController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('owners.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'rz_username' => 'required',
|
||||
'timestamp_owner_since' => 'required'
|
||||
]);
|
||||
|
||||
OwnerTransaction::create($formFields);
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function edit(OwnerTransaction $owner)
|
||||
{
|
||||
return view('owners.edit', ['owner' => $owner]);
|
||||
}
|
||||
|
||||
public function update(OwnerTransaction $owner, Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'rz_username' => 'required',
|
||||
'timestamp_owner_since' => 'required'
|
||||
]);
|
||||
|
||||
$owner->update($formFields);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function destroy(OwnerTransaction $owner)
|
||||
{
|
||||
$owner->delete();
|
||||
return back();
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PurchasingInformation;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PurchasingInformationController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('purchasings.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'price' => 'required',
|
||||
'timestamp_warranty_end' => 'required',
|
||||
'timestamp_purchase' => 'required',
|
||||
'cost_centre' => 'required',
|
||||
]);
|
||||
|
||||
PurchasingInformation::create($formFields);
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
public function edit(PurchasingInformation $purchasing)
|
||||
{
|
||||
return view('purchasings.edit', ['purchasing' => $purchasing]);
|
||||
}
|
||||
|
||||
public function update(PurchasingInformation $purchasing, Request $request)
|
||||
{
|
||||
$formFields = $request->validate([
|
||||
'price' => 'required',
|
||||
'timestamp_warranty_end' => 'required',
|
||||
'timestamp_purchase' => 'required',
|
||||
'cost_centre' => 'required',
|
||||
]);
|
||||
|
||||
$purchasing->update($formFields);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function destroy(PurchasingInformation $purchasing)
|
||||
{
|
||||
$purchasing->delete();
|
||||
return back();
|
||||
}
|
||||
}
|
@ -11,17 +11,25 @@
|
||||
<li>serial_number: {{ $device['serial_number'] }}</li>
|
||||
<li>image_url: {{ $device['image_url'] }}</li>
|
||||
</ul>
|
||||
<button><a href="{{ $device->device_id }}/edit">Edit</a></button>
|
||||
<form method="POST" action="{{ $device->device_id }}">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<button>Delete</button>
|
||||
</form>
|
||||
<x-purchasing-information :device="$device" />
|
||||
@php
|
||||
$locationTransactions = $device->locations;
|
||||
$ownerTransactins = $device->owners;
|
||||
@endphp
|
||||
<h3>Location Transactions</h3>
|
||||
<button><a href="{{ $device->device_id }}/location/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>
|
||||
@foreach ($ownerTransactins as $owner)
|
||||
<x-owner-transaction :owner="$owner" />
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,4 +3,10 @@
|
||||
<li>room_code: {{ $location->room_code }}</li>
|
||||
<li>timestamp_located_since: {{ $location->timestamp_located_since }}</li>
|
||||
</ul>
|
||||
<button><a href="locations/{{ $location->location_transaction_id }}/edit">Edit</a></button>
|
||||
<form method="POST" action="locations/{{ $location->location_transaction_id }}">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<button>Delete</button>
|
||||
</form>
|
||||
</div>
|
@ -3,4 +3,10 @@
|
||||
<li>rz_username: {{ $owner->rz_username }}</li>
|
||||
<li>timestamp_owner_since: {{ $owner->timestamp_owner_since }}</li>
|
||||
</ul>
|
||||
<button><a href="owners/{{ $owner->owner_transaction_id }}/edit">Edit</a></button>
|
||||
<form method="POST" action="owners/{{ $owner->owner_transaction_id }}">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<button>Delete</button>
|
||||
</form>
|
||||
</div>
|
@ -10,4 +10,5 @@
|
||||
<li>cost_centre: {{ $purchasing->cost_centre }}</li>
|
||||
<li>seller: {{ $purchasing->seller }}</li>
|
||||
</ul>
|
||||
<button><a href="{{ $device->device_id }}/purchasing/edit">Edit</a></button>
|
||||
</div>
|
@ -2,11 +2,4 @@
|
||||
|
||||
@section('content')
|
||||
<x-device-detail :device="$device" />
|
||||
|
||||
<button><a href="{{$device->device_id}}/edit">Edit</a></button>
|
||||
<form method="POST" action="{{$device->device_id}}">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<button>Delete</button>
|
||||
</form>
|
||||
@endsection
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\DeviceController;
|
||||
use App\Http\Controllers\LocationTransactionController;
|
||||
use App\Http\Controllers\OwnerTransactionController;
|
||||
use App\Http\Controllers\PurchasingInformationController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
@ -15,16 +18,43 @@
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return redirect('/home');
|
||||
});
|
||||
Route::get('/home', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
// Devices routes
|
||||
// index - show all devices
|
||||
Route::get('/devices', [DeviceController::class, 'index']);
|
||||
// create - show device create form
|
||||
Route::get('/devices/create', [DeviceController::class, 'create'])->middleware('auth');
|
||||
// store - store new device
|
||||
Route::post('/devices', [DeviceController::class, 'store'])->middleware('auth');
|
||||
|
||||
// Device purchasing routes
|
||||
//Route::get('/devices/{device}/purchasing/create', [PurchasingInformationController::class, 'create']);
|
||||
//Route::post('/devices/{device}/purchasing', [PurchasingInformationController::class, 'store']);
|
||||
Route::get('/devices/{device}/purchasing/edit', [PurchasingInformationController::class, 'edit']);
|
||||
Route::put('/devices/{device}/purchasing', [PurchasingInformationController::class, 'update']);
|
||||
//Route::delete('/devices/{device}/purchasing', [PurchasingInformationController::class, 'destroy']);
|
||||
|
||||
// Device location routes
|
||||
Route::get('/devices/{device}/locations/create', [LocationTransactionController::class, 'create']);
|
||||
Route::post('/devices/{device}/locations', [LocationTransactionController::class, 'store']);
|
||||
Route::get('/devices/locations/{location}/edit', [LocationTransactionController::class, 'edit']);
|
||||
Route::put('/devices/locations/{location}', [LocationTransactionController::class, 'update']);
|
||||
Route::delete('/devices/locations/{location}', [LocationTransactionController::class, 'destroy']);
|
||||
|
||||
// Device owner routes
|
||||
Route::get('/devices/{device}/owners/create', [OwnerTransactionController::class, 'create']);
|
||||
Route::post('/devices/{device}/owners', [OwnerTransactionController::class, 'store']);
|
||||
Route::get('/devices/owners/{owner}/edit', [OwnerTransactionController::class, 'edit']);
|
||||
Route::put('/devices/owners/{owner}', [OwnerTransactionController::class, 'update']);
|
||||
Route::delete('/devices/owners/{owner}', [OwnerTransactionController::class, 'destroy']);
|
||||
|
||||
//
|
||||
// edit - show edit form
|
||||
Route::get('devices/{device}/edit', [DeviceController::class, 'edit'])->middleware('auth');
|
||||
// update - update device
|
||||
@ -34,6 +64,7 @@
|
||||
// show - show sigle device
|
||||
Route::get('/devices/{device}', [DeviceController::class, 'show']);
|
||||
|
||||
//User routes
|
||||
// create - show register form
|
||||
Route::get('/register', [UserController::class, 'create']);
|
||||
// store - store new user
|
||||
@ -43,4 +74,4 @@
|
||||
// authenticate - log in user
|
||||
Route::post('/users/authenticate', [UserController::class, 'authenticate']);
|
||||
// logout - log out user
|
||||
Route::post('/logout', [UserController::class, 'logout']);
|
||||
Route::post('/logout', [UserController::class, 'logout']);
|
Loading…
Reference in New Issue
Block a user