add components button

This commit is contained in:
TimmensOne 2023-03-31 10:52:12 +02:00
parent 6894c2c3c5
commit 0e1de41203
10 changed files with 205 additions and 11 deletions

View File

@ -22,7 +22,6 @@ public function create(){
public function store(Request $request){ public function store(Request $request){
$formFields = $request->validate([ $formFields = $request->validate([
//'device_id' => ['required', Rule::unique('devices', 'device_id')],
'title' => 'required', 'title' => 'required',
'device_type' => 'required', 'device_type' => 'required',
'description' => 'required', 'description' => 'required',
@ -43,7 +42,6 @@ public function edit(Device $device) {
public function update(Device $device, Request $request){ public function update(Device $device, Request $request){
$formFields = $request->validate([ $formFields = $request->validate([
//'device_id' => 'required',
'title' => 'required', 'title' => 'required',
'device_type' => 'required', 'device_type' => 'required',
'description' => 'required', 'description' => 'required',

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -11,16 +11,24 @@
<li>serial_number: {{ $device['serial_number'] }}</li> <li>serial_number: {{ $device['serial_number'] }}</li>
<li>image_url: {{ $device['image_url'] }}</li> <li>image_url: {{ $device['image_url'] }}</li>
</ul> </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" /> <x-purchasing-information :device="$device" />
@php @php
$locationTransactions = $device->locations; $locationTransactions = $device->locations;
$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>
@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>
@foreach ($ownerTransactins as $owner) @foreach ($ownerTransactins as $owner)
<x-owner-transaction :owner="$owner" /> <x-owner-transaction :owner="$owner" />
@endforeach @endforeach

View File

@ -3,4 +3,10 @@
<li>room_code: {{ $location->room_code }}</li> <li>room_code: {{ $location->room_code }}</li>
<li>timestamp_located_since: {{ $location->timestamp_located_since }}</li> <li>timestamp_located_since: {{ $location->timestamp_located_since }}</li>
</ul> </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> </div>

View File

@ -3,4 +3,10 @@
<li>rz_username: {{ $owner->rz_username }}</li> <li>rz_username: {{ $owner->rz_username }}</li>
<li>timestamp_owner_since: {{ $owner->timestamp_owner_since }}</li> <li>timestamp_owner_since: {{ $owner->timestamp_owner_since }}</li>
</ul> </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> </div>

View File

@ -10,4 +10,5 @@
<li>cost_centre: {{ $purchasing->cost_centre }}</li> <li>cost_centre: {{ $purchasing->cost_centre }}</li>
<li>seller: {{ $purchasing->seller }}</li> <li>seller: {{ $purchasing->seller }}</li>
</ul> </ul>
<button><a href="{{ $device->device_id }}/purchasing/edit">Edit</a></button>
</div> </div>

View File

@ -2,11 +2,4 @@
@section('content') @section('content')
<x-device-detail :device="$device" /> <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 @endsection

View File

@ -1,6 +1,9 @@
<?php <?php
use App\Http\Controllers\DeviceController; 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 App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
@ -15,16 +18,43 @@
| |
*/ */
Route::get('/', function () {
return redirect('/home');
});
Route::get('/home', function () { Route::get('/home', function () {
return view('welcome'); return view('welcome');
}); });
// Devices routes
// index - show all devices // index - show all devices
Route::get('/devices', [DeviceController::class, 'index']); Route::get('/devices', [DeviceController::class, 'index']);
// create - show device create form // create - show device create form
Route::get('/devices/create', [DeviceController::class, 'create'])->middleware('auth'); Route::get('/devices/create', [DeviceController::class, 'create'])->middleware('auth');
// store - store new device // store - store new device
Route::post('/devices', [DeviceController::class, 'store'])->middleware('auth'); 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 // edit - show edit form
Route::get('devices/{device}/edit', [DeviceController::class, 'edit'])->middleware('auth'); Route::get('devices/{device}/edit', [DeviceController::class, 'edit'])->middleware('auth');
// update - update device // update - update device
@ -34,6 +64,7 @@
// show - show sigle device // show - show sigle device
Route::get('/devices/{device}', [DeviceController::class, 'show']); Route::get('/devices/{device}', [DeviceController::class, 'show']);
//User routes
// create - show register form // create - show register form
Route::get('/register', [UserController::class, 'create']); Route::get('/register', [UserController::class, 'create']);
// store - store new user // store - store new user