diff --git a/app/Charts/ExampleChart.php b/app/Charts/ExampleChart.php index 0db5cf2..69bbe3f 100644 --- a/app/Charts/ExampleChart.php +++ b/app/Charts/ExampleChart.php @@ -30,10 +30,10 @@ public function build($options = null) $newCases = $data->pluck('count')->toArray(); return $this->chart->areaChart() - ->setTitle('Cases during last six months.') - ->addData('New cases', $newCases) + ->setTitle('Novi primeri zadnjih šest mesecev.') + ->addData('Primeri', $newCases) //->addData('Completed', [7, 2, 7, 2, 5, 4]) - ->setColors(['#1A56DB', '#ff6384']) + ->setColors(['#ff6384']) ->setXAxis($months) ->setToolbar(true) ->toVue(); diff --git a/app/Http/Controllers/ClientCaseContoller.php b/app/Http/Controllers/ClientCaseContoller.php index 33bf166..f4d58e6 100644 --- a/app/Http/Controllers/ClientCaseContoller.php +++ b/app/Http/Controllers/ClientCaseContoller.php @@ -60,9 +60,9 @@ public function store(Request $request) 'full_name' => $pq['full_name'], 'gender' => null, 'birthday' => null, - 'tax_number' => null, - 'social_security_number' => null, - 'description' => 'sdwwf', + 'tax_number' => $pq['tax_number'], + 'social_security_number' => $pq['social_security_number'], + 'description' => $pq['description'], 'group_id' => 2, 'type_id' => 1 ]); @@ -73,6 +73,12 @@ public function store(Request $request) 'type_id' => $pq['address']['type_id'] ]); + $person->phones()->create([ + 'nu' => $pq['phone']['nu'], + 'country_code' => $pq['phone']['country_code'], + 'type_id' => $pq['phone']['type_id'] + ]); + $person->clientCase()->create([ 'client_id' => $client->id ]); @@ -147,11 +153,11 @@ public function deleteContract(ClientCase $clientCase, String $uuid, Request $re public function show(ClientCase $clientCase) { $case = $clientCase::with([ - 'person' => fn($que) => $que->with('addresses') + 'person' => fn($que) => $que->with(['addresses', 'phones']) ])->where('active', 1)->findOrFail($clientCase->id); return Inertia::render('Cases/Show', [ - 'client' => $case->client()->with('person', fn($q) => $q->with(['addresses']))->firstOrFail(), + 'client' => $case->client()->with('person', fn($q) => $q->with(['addresses', 'phones']))->firstOrFail(), 'client_case' => $case, 'contracts' => $case->contracts() ->with(['type']) diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 9e6cb2c..b7f0e28 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -30,7 +30,7 @@ public function index(Client $client, Request $request){ public function show(Client $client, Request $request) { $data = $client::query() - ->with(['person' => fn($que) => $que->with('addresses')]) + ->with(['person' => fn($que) => $que->with(['addresses','phones'])]) ->findOrFail($client->id); return Inertia::render('Client/Show', [ @@ -56,6 +56,7 @@ public function store(Request $request) DB::transaction(function() use ($request){ $address = $request->input('address'); + $phone = $request->input('phone'); $person = \App\Models\Person\Person::create([ 'nu' => rand(100000,200000), 'first_name' => $request->input('first_name'), @@ -63,9 +64,9 @@ public function store(Request $request) 'full_name' => $request->input('full_name'), 'gender' => null, 'birthday' => null, - 'tax_number' => null, - 'social_security_number' => null, - 'description' => 'sdwwf', + 'tax_number' => $request->input('tax_number'), + 'social_security_number' => $request->input('social_security_number'), + 'description' => $request->input('description'), 'group_id' => 1, 'type_id' => 2 ]); @@ -76,6 +77,12 @@ public function store(Request $request) 'type_id' => $address['type_id'] ]); + $person->phones()->create([ + 'nu' => $phone['nu'], + 'country_code' => $phone['country_code'], + 'type_id' => $phone['type_id'] + ]); + $person->client()->create(); }); diff --git a/app/Models/Person/PersonPhone.php b/app/Models/Person/PersonPhone.php index 5b5d2b3..69612f8 100644 --- a/app/Models/Person/PersonPhone.php +++ b/app/Models/Person/PersonPhone.php @@ -12,12 +12,29 @@ class PersonPhone extends Model /** @use HasFactory<\Database\Factories\Person/PersonPhoneFactory> */ use HasFactory; + protected $fillable = [ + 'nu', + 'country_code', + 'type_id', + 'description', + 'person_id', + 'user_id' + ]; + protected $hidden = [ 'user_id', 'person_id', 'deleted' ]; + protected static function booted(){ + static::creating(function (PersonPhone $personPhone) { + if(!isset($personPhone->user_id)){ + $personPhone->user_id = auth()->id(); + } + }); + } + public function person(): BelongsTo { return $this->belongsTo(\App\Models\Person\Person::class); diff --git a/database/seeders/PersonSeeder.php b/database/seeders/PersonSeeder.php index 743f274..3d8a3c4 100644 --- a/database/seeders/PersonSeeder.php +++ b/database/seeders/PersonSeeder.php @@ -24,8 +24,8 @@ public function run(): void ]; $personGroups = [ - [ 'name' => 'client', 'description' => '', 'color_tag' => 'blue-400'], - [ 'name' => 'client case', 'description' => '', 'color_tag' => 'red-400'] + [ 'name' => 'naročnik', 'description' => '', 'color_tag' => 'blue-400'], + [ 'name' => 'primer naročnika', 'description' => '', 'color_tag' => 'red-400'] ]; $phoneTypes = [ diff --git a/resources/js/Components/PersonInfoGrid.vue b/resources/js/Components/PersonInfoGrid.vue index ab34046..33ba7d3 100644 --- a/resources/js/Components/PersonInfoGrid.vue +++ b/resources/js/Components/PersonInfoGrid.vue @@ -24,11 +24,18 @@ const props = defineProps({
Social security NU.
{{ person.social_security_number }}
-Address
-{{ person.address }}
+{{ person.main_address }}
Phone
+{{ person.main_phone }}
+Description
{{ person.description }}