forked from invoiceninja/invoiceninja
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly call the service() method, rather than obfuscate. (invoice…
…ninja#3281) * Include fix as describe by @michael-hampton here invoiceninja#3280 * Refactor createinvitations away from jobs * Clean up * Fixes for service() refactoring * Fixes for services refactor
- Loading branch information
Showing
22 changed files
with
106 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Invoice Ninja (https://invoiceninja.com) | ||
* | ||
* @link https://github.com/invoiceninja/invoiceninja source repository | ||
* | ||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||
* | ||
* @license https://opensource.org/licenses/AAL | ||
*/ | ||
|
||
namespace App\Services\Invoice; | ||
|
||
|
||
use App\Factory\InvoiceInvitationFactory; | ||
use App\Models\Invoice; | ||
use App\Models\InvoiceInvitation; | ||
|
||
class CreateInvitations | ||
{ | ||
|
||
public function __construct() | ||
{ | ||
} | ||
|
||
public function __invoke($invoice) | ||
{ | ||
|
||
$contacts = $invoice->client->contacts; | ||
|
||
$contacts->each(function ($contact) use($invoice){ | ||
$invitation = InvoiceInvitation::whereCompanyId($invoice->company_id) | ||
->whereClientContactId($contact->id) | ||
->whereInvoiceId($invoice->id) | ||
->first(); | ||
|
||
if (!$invitation && $contact->send_invoice) { | ||
$ii = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id); | ||
$ii->invoice_id = $invoice->id; | ||
$ii->client_contact_id = $contact->id; | ||
$ii->save(); | ||
} elseif ($invitation && !$contact->send_invoice) { | ||
$invitation->delete(); | ||
} | ||
}); | ||
|
||
return $invoice; | ||
} | ||
} |
Oops, something went wrong.