mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 02:44:35 -04:00
Design repository
This commit is contained in:
parent
dbff1ab6ab
commit
6b7db63e66
54
app/Events/Design/DesignWasArchived.php
Normal file
54
app/Events/Design/DesignWasArchived.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?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\Events\Design;
|
||||||
|
|
||||||
|
use App\Models\Design;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DesignWasArchived.
|
||||||
|
*/
|
||||||
|
class DesignWasArchived
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Design
|
||||||
|
*/
|
||||||
|
public $design;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Design $design
|
||||||
|
*/
|
||||||
|
public function __construct(Design $design)
|
||||||
|
{
|
||||||
|
$this->design = $design;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
48
app/Events/Design/DesignWasCreated.php
Normal file
48
app/Events/Design/DesignWasCreated.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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\Events\Client;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DesignWasCreated.
|
||||||
|
*/
|
||||||
|
class DesignWasCreated
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Design
|
||||||
|
*/
|
||||||
|
public $design;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Design $design
|
||||||
|
*/
|
||||||
|
public function __construct(Design $design)
|
||||||
|
{
|
||||||
|
$this->design = $design;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
49
app/Events/Design/DesignWasDeleted.php
Normal file
49
app/Events/Design/DesignWasDeleted.php
Normal file
@ -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\Events\Client;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DesignWasDeleted.
|
||||||
|
*/
|
||||||
|
class DesignWasDeleted
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Design
|
||||||
|
*/
|
||||||
|
public $design;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Design $design
|
||||||
|
*/
|
||||||
|
public function __construct(Design $design)
|
||||||
|
{
|
||||||
|
$this->design = $design;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
app/Events/Design/DesignWasRestored.php
Normal file
48
app/Events/Design/DesignWasRestored.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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\Events\Client;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DesignWasRestored.
|
||||||
|
*/
|
||||||
|
class DesignWasRestored
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Design
|
||||||
|
*/
|
||||||
|
public $design;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Design $design
|
||||||
|
*/
|
||||||
|
public function __construct(Design $design)
|
||||||
|
{
|
||||||
|
$this->design = $design;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
49
app/Events/Design/DesignWasUpdated.php
Normal file
49
app/Events/Design/DesignWasUpdated.php
Normal file
@ -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\Events\Client;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DesignWasUpdated.
|
||||||
|
*/
|
||||||
|
class DesignWasUpdated
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Design
|
||||||
|
*/
|
||||||
|
public $design;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Design $design
|
||||||
|
*/
|
||||||
|
public function __construct(Design $design)
|
||||||
|
{
|
||||||
|
$this->design = $design;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,7 @@ use App\Http\Requests\Design\StoreDesignRequest;
|
|||||||
use App\Http\Requests\Design\UpdateDesignRequest;
|
use App\Http\Requests\Design\UpdateDesignRequest;
|
||||||
use App\Jobs\Entity\ActionEntity;
|
use App\Jobs\Entity\ActionEntity;
|
||||||
use App\Models\Design;
|
use App\Models\Design;
|
||||||
|
use App\Repositories\DesignRepository;
|
||||||
use App\Transformers\DesignTransformer;
|
use App\Transformers\DesignTransformer;
|
||||||
use App\Utils\Traits\BulkOptions;
|
use App\Utils\Traits\BulkOptions;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -40,14 +41,17 @@ class DesignController extends BaseController
|
|||||||
|
|
||||||
protected $entity_transformer = DesignTransformer::class;
|
protected $entity_transformer = DesignTransformer::class;
|
||||||
|
|
||||||
|
protected $design_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DesignController constructor.
|
* DesignController constructor.
|
||||||
* @param DesignRepository $designRepo
|
* @param DesignRepository $designRepo
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(DesignRepository $design_repo)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->design_repo = $design_repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -480,7 +484,7 @@ class DesignController extends BaseController
|
|||||||
|
|
||||||
$designs->each(function ($design, $key) use ($action) {
|
$designs->each(function ($design, $key) use ($action) {
|
||||||
if (auth()->user()->can('edit', $design)) {
|
if (auth()->user()->can('edit', $design)) {
|
||||||
//$this->design_repo->{$action}($design);@todo
|
$this->design_repo->{$action}($design);@todo
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -11,10 +11,18 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Events\Client\ClientWasArchived;
|
||||||
use App\Events\Client\ClientWasCreated;
|
use App\Events\Client\ClientWasCreated;
|
||||||
|
use App\Events\Client\ClientWasDeleted;
|
||||||
|
use App\Events\Client\ClientWasRestored;
|
||||||
|
use App\Events\Client\ClientWasUpdated;
|
||||||
|
use App\Events\Client\DesignWasDeleted;
|
||||||
|
use App\Events\Client\DesignWasRestored;
|
||||||
|
use App\Events\Client\DesignWasUpdated;
|
||||||
use App\Events\Company\CompanyWasDeleted;
|
use App\Events\Company\CompanyWasDeleted;
|
||||||
use App\Events\Contact\ContactLoggedIn;
|
use App\Events\Contact\ContactLoggedIn;
|
||||||
use App\Events\Credit\CreditWasMarkedSent;
|
use App\Events\Credit\CreditWasMarkedSent;
|
||||||
|
use App\Events\Design\DesignWasArchived;
|
||||||
use App\Events\Invoice\InvoiceWasCancelled;
|
use App\Events\Invoice\InvoiceWasCancelled;
|
||||||
use App\Events\Invoice\InvoiceWasCreated;
|
use App\Events\Invoice\InvoiceWasCreated;
|
||||||
use App\Events\Invoice\InvoiceWasDeleted;
|
use App\Events\Invoice\InvoiceWasDeleted;
|
||||||
@ -78,11 +86,6 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
ContactLoggedIn::class => [
|
ContactLoggedIn::class => [
|
||||||
UpdateContactLastLogin::class,
|
UpdateContactLastLogin::class,
|
||||||
],
|
],
|
||||||
// Clients
|
|
||||||
ClientWasCreated::class => [
|
|
||||||
CreatedClientActivity::class,
|
|
||||||
// 'App\Listeners\SubscriptionListener@createdClient',
|
|
||||||
],
|
|
||||||
PaymentWasCreated::class => [
|
PaymentWasCreated::class => [
|
||||||
PaymentCreatedActivity::class,
|
PaymentCreatedActivity::class,
|
||||||
PaymentNotification::class,
|
PaymentNotification::class,
|
||||||
@ -96,24 +99,29 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
PaymentWasVoided::class => [
|
PaymentWasVoided::class => [
|
||||||
PaymentVoidedActivity::class,
|
PaymentVoidedActivity::class,
|
||||||
],
|
],
|
||||||
'App\Events\ClientWasArchived' => [
|
// Clients
|
||||||
'App\Listeners\ActivityListener@archivedClient',
|
ClientWasCreated::class =>[
|
||||||
|
CreatedClientActivity::class,
|
||||||
],
|
],
|
||||||
'App\Events\ClientWasUpdated' => [
|
ClientWasArchived::class =>[
|
||||||
'App\Listeners\SubscriptionListener@updatedClient',
|
|
||||||
],
|
],
|
||||||
'App\Events\ClientWasDeleted' => [
|
ClientWasUpdated::class =>[
|
||||||
'App\Listeners\ActivityListener@deletedClient',
|
|
||||||
'App\Listeners\SubscriptionListener@deletedClient',
|
|
||||||
'App\Listeners\HistoryListener@deletedClient',
|
|
||||||
],
|
],
|
||||||
'App\Events\ClientWasRestored' => [
|
ClientWasDeleted::class =>[
|
||||||
'App\Listeners\ActivityListener@restoredClient',
|
],
|
||||||
|
ClientWasRestored::class =>[
|
||||||
],
|
],
|
||||||
|
|
||||||
CreditWasMarkedSent::class => [
|
CreditWasMarkedSent::class => [
|
||||||
],
|
],
|
||||||
|
//Designs
|
||||||
|
DesignWasArchived::class => [
|
||||||
|
],
|
||||||
|
DesignWasUpdated::class => [
|
||||||
|
],
|
||||||
|
DesignWasDeleted::class => [
|
||||||
|
],
|
||||||
|
DesignWasRestored::class => [
|
||||||
|
],
|
||||||
//Invoices
|
//Invoices
|
||||||
InvoiceWasMarkedSent::class => [
|
InvoiceWasMarkedSent::class => [
|
||||||
CreateInvoiceHtmlBackup::class,
|
CreateInvoiceHtmlBackup::class,
|
||||||
|
@ -203,13 +203,14 @@ class BaseRepository
|
|||||||
$lcfirst_resource_id = lcfirst($resource) . '_id';
|
$lcfirst_resource_id = lcfirst($resource) . '_id';
|
||||||
|
|
||||||
if ($class->name == Invoice::class || $class->name == Quote::class) {
|
if ($class->name == Invoice::class || $class->name == Quote::class) {
|
||||||
|
info("class name = invoice");
|
||||||
$state['starting_amount'] = $model->amount;
|
$state['starting_amount'] = $model->amount;
|
||||||
|
info("starting amount = {$model->amount}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$model->id) {
|
if (!$model->id) {
|
||||||
$company_defaults = $client->setCompanyDefaults($data, lcfirst($resource));
|
$company_defaults = $client->setCompanyDefaults($data, lcfirst($resource));
|
||||||
$model->uses_inclusive_taxes = $client->getSetting('inclusive_taxes');
|
$model->uses_inclusive_taxes = $client->getSetting('inclusive_taxes');
|
||||||
|
|
||||||
$data = array_merge($company_defaults, $data);
|
$data = array_merge($company_defaults, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +282,10 @@ class BaseRepository
|
|||||||
$model->service()->createInvitations();
|
$model->service()->createInvitations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$model = $model->calc()->getInvoice();
|
||||||
$state['finished_amount'] = $model->amount;
|
$state['finished_amount'] = $model->amount;
|
||||||
|
|
||||||
|
info("finished amount = {$model->amount}");
|
||||||
|
|
||||||
$model = $model->service()->applyNumber()->save();
|
$model = $model->service()->applyNumber()->save();
|
||||||
|
|
||||||
@ -291,11 +295,11 @@ class BaseRepository
|
|||||||
|
|
||||||
if ($class->name == Invoice::class) {
|
if ($class->name == Invoice::class) {
|
||||||
if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) {
|
if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) {
|
||||||
|
info("inside ledger updating");
|
||||||
$model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount']));
|
$model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount']));
|
||||||
|
$model->client->service()->updateBalance(($state['finished_amount'] - $state['starting_amount']))->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$model = $model->calc()->getInvoice();
|
|
||||||
|
|
||||||
event(new InvoiceWasUpdated($model, $model->company));
|
event(new InvoiceWasUpdated($model, $model->company));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
40
app/Repositories/DesignRepository.php
Normal file
40
app/Repositories/DesignRepository.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?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\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 DesignRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
use MakesInvoiceHtml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the class name.
|
||||||
|
*
|
||||||
|
* @return string The class name.
|
||||||
|
*/
|
||||||
|
public function getClassName()
|
||||||
|
{
|
||||||
|
return Design::class;
|
||||||
|
}
|
||||||
|
}
|
@ -84,6 +84,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
|||||||
Route::post('migrate', 'MigrationController@index')->name('migrate.start');
|
Route::post('migrate', 'MigrationController@index')->name('migrate.start');
|
||||||
|
|
||||||
Route::resource('designs', 'DesignController');// name = (payments. index / create / show / update / destroy / edit
|
Route::resource('designs', 'DesignController');// name = (payments. index / create / show / update / destroy / edit
|
||||||
|
Route::post('designs/bulk', 'DesignController@bulk')->name('designs.bulk');
|
||||||
|
|
||||||
Route::get('users', 'UserController@index');
|
Route::get('users', 'UserController@index');
|
||||||
Route::put('users/{user}', 'UserController@update')->middleware('password_protected');
|
Route::put('users/{user}', 'UserController@update')->middleware('password_protected');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user