This commit is contained in:
Simon Pocrnjič
2025-01-02 18:38:47 +01:00
parent 0c3bbfe18f
commit 0f8cfd3f16
41 changed files with 2013 additions and 591 deletions
+15 -2
View File
@@ -131,7 +131,14 @@ public function storeActivity(ClientCase $clientCase, Request $request) {
]);
//Create activity
$clientCase->activities()->create($attributes);
$activity = $clientCase->activities()->create($attributes);
foreach ($activity->decision->events as $e) {
$class = '\\App\\Events\\' . $e->name;
event(new $class($clientCase));
}
return to_route('clientCase.show', $clientCase);
@@ -156,6 +163,11 @@ public function show(ClientCase $clientCase)
'person' => fn($que) => $que->with(['addresses', 'phones'])
])->where('active', 1)->findOrFail($clientCase->id);
$types = [
'address_types' => \App\Models\Person\AddressType::all(),
'phone_types' => \App\Models\Person\PhoneType::all()
];
return Inertia::render('Cases/Show', [
'client' => $case->client()->with('person', fn($q) => $q->with(['addresses', 'phones']))->firstOrFail(),
'client_case' => $case,
@@ -166,7 +178,8 @@ public function show(ClientCase $clientCase)
->orderByDesc('created_at')
->paginate(20, ['*'], 'activities'),
'contract_types' => \App\Models\ContractType::whereNull('deleted_at')->get(),
'actions' => \App\Models\Action::with('decisions')->get()
'actions' => \App\Models\Action::with('decisions')->get(),
'types' => $types
]);
}
+11
View File
@@ -33,6 +33,11 @@ public function show(Client $client, Request $request) {
->with(['person' => fn($que) => $que->with(['addresses','phones'])])
->findOrFail($client->id);
$types = [
'address_types' => \App\Models\Person\AddressType::all(),
'phone_types' => \App\Models\Person\PhoneType::all()
];
return Inertia::render('Client/Show', [
'client' => $data,
'client_cases' => $data->clientCases()
@@ -47,6 +52,7 @@ public function show(Client $client, Request $request) {
->orderByDesc('created_at')
->paginate(15)
->withQueryString(),
'types' => $types,
'filters' => $request->only(['search'])
]);
}
@@ -91,4 +97,9 @@ public function store(Request $request)
return to_route('client');
}
public function update(Client $client, Request $request) {
return to_route('client.show', $client);
}
}
+88
View File
@@ -4,6 +4,7 @@
use App\Models\Person\Person;
use Illuminate\Http\Request;
use Inertia\Inertia;
class PersonController extends Controller
{
@@ -19,4 +20,91 @@ public function create(Request $request){
public function store(Request $request){
}
public function update(Person $person, Request $request){
$attributes = $request->validate([
'full_name' => 'string|max:255',
'tax_number' => 'nullable|integer',
'social_security_number' => 'nullable|integer',
'description' => 'nullable|string|max:500'
]);
$person->update($attributes);
return response()->json([
'person' => [
'full_name' => $person->full_name,
'tax_number' => $person->tax_number,
'social_security_number' => $person->social_security_number,
'description' => $person->description
]
]);
}
public function createAddress(Person $person, Request $request){
$attributes = $request->validate([
'address' => 'required|string|max:150',
'country' => 'nullable|string',
'type_id' => 'required|integer|exists:address_types,id',
'description' => 'nullable|string|max:125'
]);
$address_id = $person->addresses()->create($attributes)->id;
return response()->json([
'address' => \App\Models\Person\PersonAddress::with(['type'])->findOrFail($address_id)
]);
}
public function updateAddress(Person $person, int $address_id, Request $request)
{
$attributes = $request->validate([
'address' => 'required|string|max:150',
'country' => 'nullable|string',
'type_id' => 'required|integer|exists:address_types,id',
'description' => 'nullable|string|max:125'
]);
$address = $person->addresses()->with(['type'])->findOrFail($address_id);
$address->update($attributes);
return response()->json([
'address' => $address
]);
}
public function createPhone(Person $person, Request $request)
{
$attributes = $request->validate([
'nu' => 'required|string|max:50',
'country_code' => 'nullable|integer',
'type_id' => 'required|integer|exists:phone_types,id',
'description' => 'nullable|string|max:125'
]);
$phone_id = $person->phones()->create($attributes)->id;
return response()->json([
'phone' => \App\Models\Person\PersonPhone::with(['type'])->findOrFail($phone_id)
]);
}
public function updatePhone(Person $person, int $phone_id, Request $request)
{
$attributes = $request->validate([
'nu' => 'required|string|max:50',
'country_code' => 'nullable|integer',
'type_id' => 'required|integer|exists:phone_types,id',
'description' => 'nullable|string|max:125'
]);
$phone = $person->phones()->with(['type'])->findOrFail($phone_id);
$phone->update($attributes);
return response()->json([
'phone' => $phone
]);
}
}
+2 -2
View File
@@ -13,10 +13,10 @@ public function index(Request $request){
return Inertia::render('Settings/Index', [
'actions' => \App\Models\Action::query()
->with('decisions', fn($q) => $q->get(['decisions.id']))
->with('decisions')
->get(),
'decisions' => \App\Models\Decision::query()
->with('actions', fn($q) => $q->get(['actions.id']))
->with('actions')
->get()
]
);