mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 01:04:36 -04:00
Working on activities
This commit is contained in:
parent
9717424ce1
commit
e7a1e4c4db
@ -13,6 +13,8 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Factory\VendorFactory;
|
use App\Factory\VendorFactory;
|
||||||
use App\Filters\VendorFilters;
|
use App\Filters\VendorFilters;
|
||||||
|
use App\Utils\Ninja;
|
||||||
|
use App\Events\Vendor\VendorWasCreated;
|
||||||
use App\Http\Requests\Vendor\CreateVendorRequest;
|
use App\Http\Requests\Vendor\CreateVendorRequest;
|
||||||
use App\Http\Requests\Vendor\DestroyVendorRequest;
|
use App\Http\Requests\Vendor\DestroyVendorRequest;
|
||||||
use App\Http\Requests\Vendor\EditVendorRequest;
|
use App\Http\Requests\Vendor\EditVendorRequest;
|
||||||
@ -376,6 +378,8 @@ class VendorController extends BaseController
|
|||||||
|
|
||||||
$this->uploadLogo($request->file('company_logo'), $vendor->company, $vendor);
|
$this->uploadLogo($request->file('company_logo'), $vendor->company, $vendor);
|
||||||
|
|
||||||
|
event(new VendorWasCreated($vendor, $vendor->company, Ninja::eventVars()));
|
||||||
|
|
||||||
return $this->itemResponse($vendor);
|
return $this->itemResponse($vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
54
app/Listeners/Activity/CreatedVendorActivity.php
Normal file
54
app/Listeners/Activity/CreatedVendorActivity.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\Listeners\Activity;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use stdClass;
|
||||||
|
|
||||||
|
class CreatedVendorActivity implements ShouldQueue
|
||||||
|
{
|
||||||
|
protected $activity_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @param ActivityRepository $activity_repo
|
||||||
|
*/
|
||||||
|
public function __construct(ActivityRepository $activity_repo)
|
||||||
|
{
|
||||||
|
$this->activity_repo = $activity_repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
|
$fields = new stdClass;
|
||||||
|
|
||||||
|
$fields->vendor_id = $event->vendor->id;
|
||||||
|
$fields->user_id = $event->vendor->user_id;
|
||||||
|
$fields->company_id = $event->vendor->company_id;
|
||||||
|
$fields->activity_type_id = Activity::CREATE_VENDOR;
|
||||||
|
|
||||||
|
$this->activity_repo->save($fields, $event->vendor, $event->event_vars);
|
||||||
|
}
|
||||||
|
}
|
@ -47,7 +47,7 @@ class Activity extends StaticModel
|
|||||||
const RESTORE_PAYMENT = 27; //
|
const RESTORE_PAYMENT = 27; //
|
||||||
const RESTORE_CREDIT = 28; //
|
const RESTORE_CREDIT = 28; //
|
||||||
const APPROVE_QUOTE = 29; //
|
const APPROVE_QUOTE = 29; //
|
||||||
const CREATE_VENDOR = 30;
|
const CREATE_VENDOR = 30; //
|
||||||
const ARCHIVE_VENDOR = 31;
|
const ARCHIVE_VENDOR = 31;
|
||||||
const DELETE_VENDOR = 32;
|
const DELETE_VENDOR = 32;
|
||||||
const RESTORE_VENDOR = 33;
|
const RESTORE_VENDOR = 33;
|
||||||
|
@ -60,8 +60,10 @@ use App\Events\Quote\QuoteWasViewed;
|
|||||||
use App\Events\User\UserLoggedIn;
|
use App\Events\User\UserLoggedIn;
|
||||||
use App\Events\User\UserWasCreated;
|
use App\Events\User\UserWasCreated;
|
||||||
use App\Events\User\UserWasDeleted;
|
use App\Events\User\UserWasDeleted;
|
||||||
|
use App\Events\Vendor\VendorWasCreated;
|
||||||
use App\Listeners\Activity\ArchivedClientActivity;
|
use App\Listeners\Activity\ArchivedClientActivity;
|
||||||
use App\Listeners\Activity\CreatedClientActivity;
|
use App\Listeners\Activity\CreatedClientActivity;
|
||||||
|
use App\Listeners\Activity\CreatedVendorActivity;
|
||||||
use App\Listeners\Activity\CreatedCreditActivity;
|
use App\Listeners\Activity\CreatedCreditActivity;
|
||||||
use App\Listeners\Activity\CreatedQuoteActivity;
|
use App\Listeners\Activity\CreatedQuoteActivity;
|
||||||
use App\Listeners\Activity\CreditArchivedActivity;
|
use App\Listeners\Activity\CreditArchivedActivity;
|
||||||
@ -286,6 +288,10 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
QuoteWasRestored::class => [
|
QuoteWasRestored::class => [
|
||||||
QuoteRestoredActivity::class,
|
QuoteRestoredActivity::class,
|
||||||
],
|
],
|
||||||
|
VendorWasCreated::class => [
|
||||||
|
CreatedVendorActivity::class,
|
||||||
|
]
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1379,7 +1379,7 @@ $contact = ClientContact::factory()->create([
|
|||||||
])->post('/api/v1/payments/bulk?action=delete', $data);
|
])->post('/api/v1/payments/bulk?action=delete', $data);
|
||||||
|
|
||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
info(print_r($arr,1));
|
|
||||||
$this->assertEquals(1, $arr['data'][0]['is_deleted']);
|
$this->assertEquals(1, $arr['data'][0]['is_deleted']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user