Fixes for client display_name (#3137)

* Minor fixes for OpenAPI docs for clients

* Add fields to company transformer

* Padding email templates, system level and custom

* Set Unique value on client_contact_id & invoice_id on invitations table

* Fix for client display_name
This commit is contained in:
David Bomba 2019-12-08 18:33:44 +11:00 committed by GitHub
parent 259a28099f
commit 90eeb59754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 12 additions and 10 deletions

View File

@ -112,7 +112,7 @@ class TemplateController extends BaseController
$body = request()->input('body'); $body = request()->input('body');
$data = [ $data = [
'subject' => Parsedown::instance()->text(request()->input('subject')), 'subject' => request()->input('subject'),
'body' => Parsedown::instance()->text(request()->input('body')), 'body' => Parsedown::instance()->text(request()->input('body')),
]; ];

View File

@ -84,6 +84,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference
'custom_value3', 'custom_value3',
'custom_value4', 'custom_value4',
'email', 'email',
'is_primary',
]; ];
public function getHashedIdAttribute() public function getHashedIdAttribute()

View File

@ -34,14 +34,12 @@ class ClientContactRepository extends BaseRepository
}); });
$this->is_primary = true;
/* Set first record to primary - always */ /* Set first record to primary - always */
$contacts = $contacts->sortBy('is_primary'); $contacts = $contacts->sortBy('is_primary')->map(function ($contact){
$contact['is_primary'] = $this->is_primary;
$contacts->first(function($contact){ $this->is_primary = false;
return $contact;
$contact['is_primary'] = true;
// $contact->save();
}); });
//loop and update/create contacts //loop and update/create contacts
@ -66,6 +64,8 @@ class ClientContactRepository extends BaseRepository
$update_contact->save(); $update_contact->save();
}); });
//always made sure we have one blank contact to maintain state //always made sure we have one blank contact to maintain state
if($contacts->count() == 0) if($contacts->count() == 0)
{ {

View File

@ -72,7 +72,6 @@ class ClientRepository extends BaseRepository
if(isset($data['contacts'])) if(isset($data['contacts']))
$contacts = $this->contact_repo->save($data['contacts'], $client); $contacts = $this->contact_repo->save($data['contacts'], $client);
if(empty($data['name'])) if(empty($data['name']))
$data['name'] = $client->present()->name(); $data['name'] = $client->present()->name();

View File

@ -705,6 +705,7 @@ class CreateUsersTable extends Migration
$t->softDeletes('deleted_at', 6); $t->softDeletes('deleted_at', 6);
$t->index(['deleted_at', 'invoice_id']); $t->index(['deleted_at', 'invoice_id']);
$t->unique(['client_contact_id', 'invoice_id']);
}); });

View File

@ -0,0 +1 @@
{{ $body }}