95 lines
3.6 KiB
PHP
95 lines
3.6 KiB
PHP
<?php
|
|
|
|
use App\Charts\ExampleChart;
|
|
use App\Http\Controllers\ClientCaseContoller;
|
|
use App\Http\Controllers\ClientController;
|
|
use App\Http\Controllers\ContractController;
|
|
use App\Http\Controllers\SettingController;
|
|
use App\Models\Person\Person;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Http\Request;
|
|
use ArielMejiaDev\LarapexCharts\LarapexChart;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Inertia\Inertia;
|
|
|
|
Route::redirect('/', 'login');
|
|
|
|
Route::middleware([
|
|
'auth:sanctum',
|
|
config('jetstream.auth_session'),
|
|
'verified',
|
|
])->group(function () {
|
|
Route::get('/dashboard', function () {
|
|
$chart = new ExampleChart(new LarapexChart());
|
|
$people = Person::with(['group','type', 'client', 'clientCase'])
|
|
->where([
|
|
['active','=',1],
|
|
])
|
|
->limit(10)
|
|
->orderByDesc('created_at')
|
|
->get();
|
|
|
|
return Inertia::render(
|
|
'Dashboard',
|
|
[
|
|
'chart' => $chart->build(),
|
|
'people' => $people
|
|
]
|
|
);
|
|
})->name('dashboard');
|
|
|
|
Route::get('testing', function() {
|
|
return Inertia::render('Testing', []);
|
|
});
|
|
|
|
Route::get('search', function(Request $request) {
|
|
|
|
if( !empty($request->input('query')) ) {
|
|
/*$clients = App\Models\Client::search($request->input('query'))
|
|
->query(function($q) use($request) {
|
|
$q->with('person')->limit($request->input('limit'));
|
|
})
|
|
->get();*/
|
|
$clients = App\Models\Client::search($request->input('query'))
|
|
->query( fn(Builder $builder) =>
|
|
$builder->with('person:id,full_name')->limit($request->input('limit'))
|
|
)
|
|
->get();
|
|
|
|
$clientCases = App\Models\ClientCase::search($request->input('query'))
|
|
->query( fn(Builder $builder) =>
|
|
$builder->with('person:id,full_name')->limit($request->input('limit'))
|
|
)
|
|
->get();
|
|
|
|
|
|
return [
|
|
'clients' => $clients,
|
|
'client_cases' => $clientCases
|
|
];
|
|
|
|
}
|
|
|
|
return [];
|
|
})->name('search');
|
|
|
|
//client
|
|
Route::get('clients', [ClientController::class, 'index'])->name('client');
|
|
Route::get('clients/{client:uuid}', [ClientController::class, 'show'])->name('client.show');
|
|
Route::post('clients', [ClientController::class, 'store'])->name('client.store');
|
|
|
|
//client-case
|
|
Route::get('client-cases', [ClientCaseContoller::class, 'index'])->name('clientCase');
|
|
Route::get('client-cases/{client_case:uuid}', [ClientCaseContoller::class, 'show'])->name('clientCase.show');
|
|
Route::post('client-cases', [ClientCaseContoller::class, 'store'])->name('clientCase.store');
|
|
//client-case / contract
|
|
Route::post('client-cases/{client_case:uuid}/contract', [ClientCaseContoller::class, 'storeContract'])->name('clientCase.contract.store');
|
|
Route::put('client-cases/{client_case:uuid}/contract/{uuid}', [ClientCaseContoller::class, 'updateContract'])->name('clientCase.contract.update');
|
|
Route::delete('client-cases/{client_case:uuid}/contract/{uuid}', [ClientCaseContoller::class, 'deleteContract'])->name('clientCase.contract.delete');
|
|
//client-case / activity
|
|
Route::post('client-cases/{client_case:uuid}/activity', [ClientCaseContoller::class, 'storeActivity'])->name('clientCase.activity.store');
|
|
|
|
Route::get('settings', [SettingController::class, 'index'])->name('settings');
|
|
|
|
});
|