mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Redundant code cleanup
This commit is contained in:
parent
552ac4ee8f
commit
13a00fc897
@ -34,24 +34,6 @@ class BaseRepository
|
|||||||
use MakesHash;
|
use MakesHash;
|
||||||
use SavesDocuments;
|
use SavesDocuments;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return null
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private function getInstance()
|
|
||||||
{
|
|
||||||
$className = $this->getClassName();
|
|
||||||
|
|
||||||
return new $className();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $entity
|
* @param $entity
|
||||||
* @param $type
|
* @param $type
|
||||||
@ -153,25 +135,6 @@ class BaseRepository
|
|||||||
return count($entities);
|
return count($entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $ids
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function findByPublicIds($ids)
|
|
||||||
{
|
|
||||||
return $this->getInstance()->scope($ids)->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $ids
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function findByPublicIdsWithTrashed($ids)
|
|
||||||
{
|
|
||||||
return $this->getInstance()->scope($ids)->withTrashed()->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getInvitation($invitation, $resource)
|
public function getInvitation($invitation, $resource)
|
||||||
{
|
{
|
||||||
|
@ -39,17 +39,7 @@ class ClientRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
$this->contact_repo = $contact_repo;
|
$this->contact_repo = $contact_repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Client::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the client and its contacts.
|
* Saves the client and its contacts.
|
||||||
*
|
*
|
||||||
|
@ -23,16 +23,6 @@ class CompanyRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Company::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the client and its contacts.
|
* Saves the client and its contacts.
|
||||||
*
|
*
|
||||||
|
@ -30,15 +30,6 @@ class CreditRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Credit::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the client and its contacts.
|
* Saves the client and its contacts.
|
||||||
|
@ -11,30 +11,10 @@
|
|||||||
|
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Libraries\MultiDB;
|
|
||||||
use App\Models\Activity;
|
|
||||||
use App\Models\Backup;
|
|
||||||
use App\Models\Client;
|
|
||||||
use App\Models\Design;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Utils\Traits\MakesInvoiceHtml;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for activity repository.
|
* Class for DesignRepository .
|
||||||
*/
|
*/
|
||||||
class DesignRepository extends BaseRepository
|
class DesignRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
use MakesInvoiceHtml;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Design::class;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,15 +19,6 @@ use App\Utils\Ninja;
|
|||||||
*/
|
*/
|
||||||
class DocumentRepository extends BaseRepository
|
class DocumentRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Document::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete($document)
|
public function delete($document)
|
||||||
{
|
{
|
||||||
|
@ -24,19 +24,6 @@ class ExpenseRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
use GeneratesCounter;
|
use GeneratesCounter;
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Expense::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the expense and its contacts.
|
* Saves the expense and its contacts.
|
||||||
|
@ -12,21 +12,9 @@
|
|||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
use App\Models\GroupSetting;
|
use App\Models\GroupSetting;
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
|
|
||||||
class GroupSettingRepository extends BaseRepository
|
class GroupSettingRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
use MakesHash;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return GroupSetting::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save($data, GroupSetting $group_setting) :?GroupSetting
|
public function save($data, GroupSetting $group_setting) :?GroupSetting
|
||||||
{
|
{
|
||||||
|
@ -27,23 +27,14 @@ class InvoiceRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Invoice::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the invoices.
|
* Saves the invoices.
|
||||||
*
|
*
|
||||||
* @param array. $data The invoice data
|
* @param array $data The invoice data
|
||||||
* @param InvoiceSum|Invoice $invoice The invoice
|
* @param Invoice $invoice The invoice
|
||||||
*
|
*
|
||||||
* @return Invoice|InvoiceSum|null Returns the invoice object
|
* @return Invoice|null Returns the invoice object
|
||||||
*/
|
*/
|
||||||
public function save($data, Invoice $invoice):?Invoice
|
public function save($data, Invoice $invoice):?Invoice
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,6 @@ class PaymentMigrationRepository extends BaseRepository
|
|||||||
$this->activity_repo = new ActivityRepository();
|
$this->activity_repo = new ActivityRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Payment::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves and updates a payment. //todo refactor to handle refunds and payments.
|
* Saves and updates a payment. //todo refactor to handle refunds and payments.
|
||||||
*
|
*
|
||||||
|
@ -41,15 +41,6 @@ class PaymentRepository extends BaseRepository
|
|||||||
$this->credit_repo = $credit_repo;
|
$this->credit_repo = $credit_repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Payment::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves and updates a payment. //todo refactor to handle refunds and payments.
|
* Saves and updates a payment. //todo refactor to handle refunds and payments.
|
||||||
*
|
*
|
||||||
|
@ -19,11 +19,6 @@ class ProductRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
use SavesDocuments;
|
use SavesDocuments;
|
||||||
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Product::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @param Product $product
|
* @param Product $product
|
||||||
|
@ -19,13 +19,4 @@ use App\Models\Project;
|
|||||||
class ProjectRepository extends BaseRepository
|
class ProjectRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Project::class;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,7 @@ use Illuminate\Http\Request;
|
|||||||
*/
|
*/
|
||||||
class QuoteRepository extends BaseRepository
|
class QuoteRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
use MakesHash;
|
|
||||||
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Quote::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save($data, Quote $quote) : ?Quote
|
public function save($data, Quote $quote) : ?Quote
|
||||||
{
|
{
|
||||||
|
@ -20,10 +20,6 @@ use Illuminate\Http\Request;
|
|||||||
*/
|
*/
|
||||||
class RecurringInvoiceRepository extends BaseRepository
|
class RecurringInvoiceRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return RecurringInvoice::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save($data, RecurringInvoice $invoice) : ?RecurringInvoice
|
public function save($data, RecurringInvoice $invoice) : ?RecurringInvoice
|
||||||
{
|
{
|
||||||
|
@ -20,10 +20,7 @@ use Illuminate\Http\Request;
|
|||||||
*/
|
*/
|
||||||
class RecurringQuoteRepository extends BaseRepository
|
class RecurringQuoteRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return RecurringQuote::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save(Request $request, RecurringQuote $quote) : ?RecurringQuote
|
public function save(Request $request, RecurringQuote $quote) : ?RecurringQuote
|
||||||
{
|
{
|
||||||
@ -31,13 +28,10 @@ class RecurringQuoteRepository extends BaseRepository
|
|||||||
|
|
||||||
$quote->save();
|
$quote->save();
|
||||||
|
|
||||||
$quote_calc = new InvoiceSum($quote, $quote->settings);
|
$quote_calc = new InvoiceSum($quote);
|
||||||
|
|
||||||
$quote = $quote_calc->build()->getQuote();
|
$quote = $quote_calc->build()->getQuote();
|
||||||
|
|
||||||
//fire events here that cascading from the saving of an Quote
|
|
||||||
//ie. client balance update...
|
|
||||||
|
|
||||||
return $quote;
|
return $quote;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,19 +23,6 @@ class TaskRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
use GeneratesCounter;
|
use GeneratesCounter;
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Task::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the task and its contacts.
|
* Saves the task and its contacts.
|
||||||
|
@ -15,15 +15,7 @@ use App\Models\CompanyToken;
|
|||||||
|
|
||||||
class TokenRepository extends BaseRepository
|
class TokenRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return CompanyToken::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the companytoken.
|
* Saves the companytoken.
|
||||||
|
@ -27,24 +27,15 @@ class UserRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return User::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the user and its contacts.
|
* Saves the user and its contacts.
|
||||||
*
|
*
|
||||||
* @param array $data The data
|
* @param array $data The data
|
||||||
* @param \App\Models\user $user The user
|
* @param \App\Models\User $user The user
|
||||||
*
|
*
|
||||||
* @param bool $unset_company_user
|
* @param bool $unset_company_user
|
||||||
* @return user|\App\Models\user|null user Object
|
* @return \App\Models\User user Object
|
||||||
*/
|
*/
|
||||||
public function save(array $data, User $user, $unset_company_user = false)
|
public function save(array $data, User $user, $unset_company_user = false)
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace App\Repositories;
|
|||||||
|
|
||||||
use App\Factory\VendorFactory;
|
use App\Factory\VendorFactory;
|
||||||
use App\Models\Vendor;
|
use App\Models\Vendor;
|
||||||
use App\Repositories\VSendorContactRepository;
|
use App\Repositories\VendorContactRepository;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@ -23,37 +23,24 @@ use Illuminate\Http\Request;
|
|||||||
class VendorRepository extends BaseRepository
|
class VendorRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
use GeneratesCounter;
|
use GeneratesCounter;
|
||||||
/**
|
|
||||||
* @var vendorContactRepository
|
|
||||||
*/
|
|
||||||
protected $contact_repo;
|
protected $contact_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vendorController constructor.
|
* VendorContactRepository constructor.
|
||||||
* @param vendorContactRepository $contact_repo
|
|
||||||
*/
|
*/
|
||||||
public function __construct(VendorContactRepository $contact_repo)
|
public function __construct(VendorContactRepository $contact_repo)
|
||||||
{
|
{
|
||||||
$this->contact_repo = $contact_repo;
|
$this->contact_repo = $contact_repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the class name.
|
|
||||||
*
|
|
||||||
* @return string The class name.
|
|
||||||
*/
|
|
||||||
public function getClassName()
|
|
||||||
{
|
|
||||||
return Vendor::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the vendor and its contacts.
|
* Saves the vendor and its contacts.
|
||||||
*
|
*
|
||||||
* @param array $data The data
|
* @param array $data The data
|
||||||
* @param \App\Models\vendor $vendor The vendor
|
* @param \App\Models\Vendor $vendor The vendor
|
||||||
*
|
*
|
||||||
* @return vendor|\App\Models\vendor|null vendor Object
|
* @return vendor|\App\Models\Vendor|null Vendor Object
|
||||||
* @throws \Laracasts\Presenter\Exceptions\PresenterException
|
* @throws \Laracasts\Presenter\Exceptions\PresenterException
|
||||||
*/
|
*/
|
||||||
public function save(array $data, Vendor $vendor) : ?Vendor
|
public function save(array $data, Vendor $vendor) : ?Vendor
|
||||||
@ -70,7 +57,7 @@ class VendorRepository extends BaseRepository
|
|||||||
$vendor->save();
|
$vendor->save();
|
||||||
|
|
||||||
if (isset($data['contacts'])) {
|
if (isset($data['contacts'])) {
|
||||||
$contacts = $this->contact_repo->save($data, $vendor);
|
$this->contact_repo->save($data, $vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($data['name'])) {
|
if (empty($data['name'])) {
|
||||||
|
@ -40,7 +40,7 @@ class CreateInvitations extends AbstractService
|
|||||||
$ii->credit_id = $this->credit->id;
|
$ii->credit_id = $this->credit->id;
|
||||||
$ii->client_contact_id = $contact->id;
|
$ii->client_contact_id = $contact->id;
|
||||||
$ii->save();
|
$ii->save();
|
||||||
} elseif ($invitation && ! $contact->send_email) {
|
} elseif (! $contact->send_email) {
|
||||||
$invitation->delete();
|
$invitation->delete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -61,6 +61,11 @@
|
|||||||
<directory name="app" />
|
<directory name="app" />
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</InvalidNullableReturnType>
|
</InvalidNullableReturnType>
|
||||||
|
<ImplementedReturnTypeMismatch>
|
||||||
|
<errorLevel type="suppress">
|
||||||
|
<directory name="app" />
|
||||||
|
</errorLevel>
|
||||||
|
</ImplementedReturnTypeMismatch>
|
||||||
|
|
||||||
|
|
||||||
</issueHandlers>
|
</issueHandlers>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user