first commit
This commit is contained in:
8
app/Http/Controllers/Controller.php
Normal file
8
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
23
app/Http/Controllers/IndexController.php
Normal file
23
app/Http/Controllers/IndexController.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\SI\SttMedicalHistoryResource;
|
||||
use App\Models\SI\SttMedicalHistory;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$pageSize = $request->get('pageSize', 15);
|
||||
|
||||
$cards = SttMedicalHistory::query();
|
||||
$cards = SttMedicalHistoryResource::collection($cards->paginate($pageSize));
|
||||
|
||||
return Inertia::render('Home/Index', [
|
||||
'cards' => $cards,
|
||||
]);
|
||||
}
|
||||
}
|
||||
43
app/Http/Middleware/HandleInertiaRequests.php
Normal file
43
app/Http/Middleware/HandleInertiaRequests.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Middleware;
|
||||
|
||||
class HandleInertiaRequests extends Middleware
|
||||
{
|
||||
/**
|
||||
* The root template that's loaded on the first page visit.
|
||||
*
|
||||
* @see https://inertiajs.com/server-side-setup#root-template
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rootView = 'app';
|
||||
|
||||
/**
|
||||
* Determines the current asset version.
|
||||
*
|
||||
* @see https://inertiajs.com/asset-versioning
|
||||
*/
|
||||
public function version(Request $request): ?string
|
||||
{
|
||||
return parent::version($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the props that are shared by default.
|
||||
*
|
||||
* @see https://inertiajs.com/shared-data
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function share(Request $request): array
|
||||
{
|
||||
return [
|
||||
...parent::share($request),
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Resources/SI/SttMedicalHistoryResource.php
Normal file
30
app/Http/Resources/SI/SttMedicalHistoryResource.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\SI;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class SttMedicalHistoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'fullname' => $this->getFullNameAttribute(),
|
||||
'mpostdate' => Carbon::parse($this->mpostdate)->format('d.m.Y'),
|
||||
'menddate' => Carbon::parse($this->menddate)->format('d.m.Y'),
|
||||
'narhiv' => $this->narhiv,
|
||||
'datearhiv' => Carbon::parse($this->datearhiv)->format('d.m.Y'),
|
||||
'statgod' => $this->statgod,
|
||||
'enp' => $this->enp,
|
||||
'nkarta' => $this->nkarta,
|
||||
'dr' => Carbon::parse($this->dr)->format('d.m.Y'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user