add device controller
This commit is contained in:
parent
665916d05f
commit
5df9e492ff
24
device-app/app/Http/Controllers/DeviceController.php
Normal file
24
device-app/app/Http/Controllers/DeviceController.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Device;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class DeviceController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('devices.index', [
|
||||||
|
'devices' => Device::all()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Device $device)
|
||||||
|
{
|
||||||
|
return view('devices.show', [
|
||||||
|
'device' => $device
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
@props(['device'])
|
||||||
|
<div>
|
||||||
|
<a href="/devices/{{ $device['device_id'] }}">{{ $device->title }}</a>
|
||||||
|
</div>
|
@ -5,9 +5,7 @@
|
|||||||
@unless(count($devices) == 0)
|
@unless(count($devices) == 0)
|
||||||
<ul>
|
<ul>
|
||||||
@foreach ($devices as $device)
|
@foreach ($devices as $device)
|
||||||
<li>
|
<x-device-card :device="$device" />
|
||||||
<a href="/devices/{{ $device['device_id'] }}">{{ $device->title }}</a>
|
|
||||||
</li>
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
@else
|
@else
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\DeviceController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use App\Models\Device;
|
use App\Models\Device;
|
||||||
|
|
||||||
@ -18,15 +19,6 @@
|
|||||||
return view('welcome');
|
return view('welcome');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/devices', function () {
|
Route::get('/devices', [DeviceController::class, 'index']);
|
||||||
//return view('deviceList');
|
|
||||||
return view('deviceList', [
|
|
||||||
'devices' => Device::all()
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('/devices/{device_id}', function ($device_id) {
|
Route::get('/devices/{device}', [DeviceController::class, 'show']);
|
||||||
return view('deviceDetail', [
|
|
||||||
'device' => Device::find($device_id)
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
Loading…
Reference in New Issue
Block a user