1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Ninja/Repositories/VendorContactRepository.php
Holger Lösken 0fbda85a59 Code Refactoring
- Removed unused uses
- Type hinting for method parameters
- Removed commented code
- Introduced comments for classes and methods
- Short array syntax
2016-07-03 16:19:22 +00:00

27 lines
780 B
PHP

<?php namespace App\Ninja\Repositories;
use App\Models\Vendor;
use App\Models\VendorContact;
// vendor
class VendorContactRepository extends BaseRepository
{
public function save($data)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
if (!$publicId || $publicId == '-1') {
$contact = VendorContact::createNew();
//$contact->send_invoice = true;
$contact->vendor_id = $data['vendor_id'];
$contact->is_primary = VendorContact::scope()->where('vendor_id', '=', $contact->vendor_id)->count() == 0;
} else {
$contact = VendorContact::scope($publicId)->firstOrFail();
}
$contact->fill($data);
$contact->save();
return $contact;
}
}