1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00

Changed vendorcontacts to vendor_contacts

This commit is contained in:
Hillel Coren 2016-05-04 15:16:49 +03:00
parent 9ebb539cce
commit db9d75ceff
12 changed files with 36 additions and 36 deletions

View File

@ -126,7 +126,7 @@ class CreateTestData extends Command
'city' => $this->faker->city,
'state' => $this->faker->state,
'postal_code' => $this->faker->postcode,
'vendorcontacts' => [[
'vendor_contacts' => [[
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'email' => $this->faker->safeEmail,

View File

@ -204,7 +204,7 @@ class BaseAPIController extends Controller
} elseif ($include == 'clients') {
$data[] = 'clients.contacts';
} elseif ($include == 'vendors') {
$data[] = 'vendors.vendorcontacts';
$data[] = 'vendors.vendor_contacts';
} elseif ($include) {
$data[] = $include;
}

View File

@ -74,7 +74,7 @@ class ExpenseController extends BaseController
public function create(ExpenseRequest $request)
{
if ($request->vendor_id != 0) {
$vendor = Vendor::scope($request->vendor_id)->with('vendorcontacts')->firstOrFail();
$vendor = Vendor::scope($request->vendor_id)->with('vendor_contacts')->firstOrFail();
} else {
$vendor = null;
}
@ -85,7 +85,7 @@ class ExpenseController extends BaseController
'method' => 'POST',
'url' => 'expenses',
'title' => trans('texts.new_expense'),
'vendors' => Vendor::scope()->with('vendorcontacts')->orderBy('name')->get(),
'vendors' => Vendor::scope()->with('vendor_contacts')->orderBy('name')->get(),
'vendor' => $vendor,
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
'clientPublicId' => $request->client_id,
@ -124,7 +124,7 @@ class ExpenseController extends BaseController
'url' => 'expenses/'.$expense->public_id,
'title' => 'Edit Expense',
'actions' => $actions,
'vendors' => Vendor::scope()->with('vendorcontacts')->orderBy('name')->get(),
'vendors' => Vendor::scope()->with('vendor_contacts')->orderBy('name')->get(),
'vendorPublicId' => $expense->vendor ? $expense->vendor->public_id : null,
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
'clientPublicId' => $expense->client ? $expense->client->public_id : null,

View File

@ -164,12 +164,12 @@ class ExportController extends BaseController
if ($request->input(ENTITY_VENDOR)) {
$data['clients'] = Vendor::scope()
->with('user', 'vendorcontacts', 'country')
->with('user', 'vendor_contacts', 'country')
->withArchived()
->get();
$data['vendor_contacts'] = VendorContact::scope()
->with('user', 'vendor.contacts')
->with('user', 'vendor.vendor_contacts')
->withTrashed()
->get();

View File

@ -81,7 +81,7 @@ class VendorApiController extends BaseAPIController
$vendor = $this->vendorRepo->save($request->input());
$vendor = Vendor::scope($vendor->public_id)
->with('country', 'vendorcontacts', 'industry', 'size', 'currency')
->with('country', 'vendor_contacts', 'industry', 'size', 'currency')
->first();
return $this->itemResponse($vendor);

View File

@ -9,8 +9,8 @@ class VendorRequest extends EntityRequest {
$vendor = parent::entity();
// eager load the contacts
if ($vendor && ! count($vendor->vendorcontacts)) {
$vendor->load('vendorcontacts');
if ($vendor && ! count($vendor->vendor_contacts)) {
$vendor->load('vendor_contacts');
}
return $vendor;

View File

@ -95,7 +95,7 @@ class Vendor extends EntityModel
return $this->hasMany('App\Models\Payment');
}
public function vendorContacts()
public function vendor_contacts()
{
return $this->hasMany('App\Models\VendorContact');
}
@ -143,7 +143,7 @@ class Vendor extends EntityModel
$contact->fill($data);
$contact->is_primary = $isPrimary;
return $this->vendorContacts()->save($contact);
return $this->vendor_contacts()->save($contact);
}
public function getRoute()

View File

@ -16,7 +16,7 @@ class VendorRepository extends BaseRepository
public function all()
{
return Vendor::scope()
->with('user', 'vendorcontacts', 'country')
->with('user', 'vendor_contacts', 'country')
->withTrashed()
->where('is_deleted', '=', false)
->get();
@ -71,7 +71,7 @@ class VendorRepository extends BaseRepository
} elseif (!$publicId || $publicId == '-1') {
$vendor = Vendor::createNew();
} else {
$vendor = Vendor::scope($publicId)->with('vendorcontacts')->firstOrFail();
$vendor = Vendor::scope($publicId)->with('vendor_contacts')->firstOrFail();
\Log::warning('Entity not set in vendor repo save');
}
@ -79,7 +79,7 @@ class VendorRepository extends BaseRepository
$vendor->save();
$first = true;
$vendorcontacts = isset($data['vendorcontact']) ? [$data['vendorcontact']] : $data['vendorcontacts'];
$vendorcontacts = isset($data['vendor_contact']) ? [$data['vendor_contact']] : $data['vendor_contacts'];
foreach ($vendorcontacts as $vendorcontact) {
$vendorcontact = $vendor->addVendorContact($vendorcontact, $first);

View File

@ -36,7 +36,7 @@ class VendorTransformer extends EntityTransformer
*/
protected $defaultIncludes = [
'vendorContacts',
'vendor_contacts',
];
protected $availableIncludes = [
@ -47,7 +47,7 @@ class VendorTransformer extends EntityTransformer
public function includeVendorContacts(Vendor $vendor)
{
$transformer = new VendorContactTransformer($this->account, $this->serializer);
return $this->includeCollection($vendor->vendorContacts, $transformer, ENTITY_CONTACT);
return $this->includeCollection($vendor->vendor_contacts, $transformer, ENTITY_CONTACT);
}
public function includeInvoices(Vendor $vendor)

View File

@ -7,8 +7,8 @@
@section('content')
@if ($errors->first('vendorcontacts'))
<div class="alert alert-danger">{{ trans($errors->first('vendorcontacts')) }}</div>
@if ($errors->first('vendor_contacts'))
<div class="alert alert-danger">{{ trans($errors->first('vendor_contacts')) }}</div>
@endif
<div class="row">
@ -73,26 +73,26 @@
</div>
<div class="panel-body">
<div data-bind='template: { foreach: vendorcontacts,
<div data-bind='template: { foreach: vendor_contacts,
beforeRemove: hideContact,
afterAdd: showContact }'>
{!! Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown',
attr: {name: 'vendorcontacts[' + \$index() + '][public_id]'}") !!}
attr: {name: 'vendor_contacts[' + \$index() + '][public_id]'}") !!}
{!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown',
attr: {name: 'vendorcontacts[' + \$index() + '][first_name]'}") !!}
attr: {name: 'vendor_contacts[' + \$index() + '][first_name]'}") !!}
{!! Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown',
attr: {name: 'vendorcontacts[' + \$index() + '][last_name]'}") !!}
attr: {name: 'vendor_contacts[' + \$index() + '][last_name]'}") !!}
{!! Former::text('email')->data_bind("value: email, valueUpdate: 'afterkeydown',
attr: {name: 'vendorcontacts[' + \$index() + '][email]', id:'email'+\$index()}") !!}
attr: {name: 'vendor_contacts[' + \$index() + '][email]', id:'email'+\$index()}") !!}
{!! Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown',
attr: {name: 'vendorcontacts[' + \$index() + '][phone]'}") !!}
attr: {name: 'vendor_contacts[' + \$index() + '][phone]'}") !!}
<div class="form-group">
<div class="col-lg-8 col-lg-offset-4 bold">
<span class="redlink bold" data-bind="visible: $parent.vendorcontacts().length > 1">
<span class="redlink bold" data-bind="visible: $parent.vendor_contacts().length > 1">
{!! link_to('#', trans('texts.remove_contact').' -', array('data-bind'=>'click: $parent.removeContact')) !!}
</span>
<span data-bind="visible: $index() === ($parent.vendorcontacts().length - 1)" class="pull-right greenlink bold">
<span data-bind="visible: $index() === ($parent.vendor_contacts().length - 1)" class="pull-right greenlink bold">
{!! link_to('#', trans('texts.add_contact').' +', array('onclick'=>'return addContact()')) !!}
</span>
</div>
@ -186,10 +186,10 @@
function VendorModel(data) {
var self = this;
self.vendorcontacts = ko.observableArray();
self.vendor_contacts = ko.observableArray();
self.mapping = {
'vendorcontacts': {
'vendor_contacts': {
create: function(options) {
return new VendorContactModel(options.data);
}
@ -199,12 +199,12 @@
if (data) {
ko.mapping.fromJS(data, self.mapping, this);
} else {
self.vendorcontacts.push(new VendorContactModel());
self.vendor_contacts.push(new VendorContactModel());
}
self.placeholderName = ko.computed(function() {
if (self.vendorcontacts().length == 0) return '';
var contact = self.vendorcontacts()[0];
if (self.vendor_contacts().length == 0) return '';
var contact = self.vendor_contacts()[0];
if (contact.first_name() || contact.last_name()) {
return contact.first_name() + ' ' + contact.last_name();
} else {
@ -226,12 +226,12 @@
ko.applyBindings(model);
function addContact() {
model.vendorcontacts.push(new VendorContactModel());
model.vendor_contacts.push(new VendorContactModel());
return false;
}
model.removeContact = function() {
model.vendorcontacts.remove(this);
model.vendor_contacts.remove(this);
}

View File

@ -109,7 +109,7 @@
<div class="col-md-3">
<h3>{{ trans('texts.contacts') }}</h3>
@foreach ($vendor->vendorcontacts as $contact)
@foreach ($vendor->vendor_contacts as $contact)
@if ($contact->first_name || $contact->last_name)
<b>{{ $contact->first_name.' '.$contact->last_name }}</b><br/>
@endif

View File

@ -78,7 +78,7 @@ class APICest
$data = new stdClass;
$data->name = $this->faker->word;
$data->vendorcontacts = [];
$data->vendor_contacts = [];
$this->createEntity('vendor', $data);
$this->listEntities('vendor');