1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Working on activities

This commit is contained in:
David Bomba 2020-11-03 16:44:50 +11:00
parent 9717424ce1
commit e7a1e4c4db
5 changed files with 66 additions and 2 deletions

View File

@ -13,6 +13,8 @@ namespace App\Http\Controllers;
use App\Factory\VendorFactory;
use App\Filters\VendorFilters;
use App\Utils\Ninja;
use App\Events\Vendor\VendorWasCreated;
use App\Http\Requests\Vendor\CreateVendorRequest;
use App\Http\Requests\Vendor\DestroyVendorRequest;
use App\Http\Requests\Vendor\EditVendorRequest;
@ -376,6 +378,8 @@ class VendorController extends BaseController
$this->uploadLogo($request->file('company_logo'), $vendor->company, $vendor);
event(new VendorWasCreated($vendor, $vendor->company, Ninja::eventVars()));
return $this->itemResponse($vendor);
}

View 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);
}
}

View File

@ -47,7 +47,7 @@ class Activity extends StaticModel
const RESTORE_PAYMENT = 27; //
const RESTORE_CREDIT = 28; //
const APPROVE_QUOTE = 29; //
const CREATE_VENDOR = 30;
const CREATE_VENDOR = 30; //
const ARCHIVE_VENDOR = 31;
const DELETE_VENDOR = 32;
const RESTORE_VENDOR = 33;

View File

@ -60,8 +60,10 @@ use App\Events\Quote\QuoteWasViewed;
use App\Events\User\UserLoggedIn;
use App\Events\User\UserWasCreated;
use App\Events\User\UserWasDeleted;
use App\Events\Vendor\VendorWasCreated;
use App\Listeners\Activity\ArchivedClientActivity;
use App\Listeners\Activity\CreatedClientActivity;
use App\Listeners\Activity\CreatedVendorActivity;
use App\Listeners\Activity\CreatedCreditActivity;
use App\Listeners\Activity\CreatedQuoteActivity;
use App\Listeners\Activity\CreditArchivedActivity;
@ -286,6 +288,10 @@ class EventServiceProvider extends ServiceProvider
QuoteWasRestored::class => [
QuoteRestoredActivity::class,
],
VendorWasCreated::class => [
CreatedVendorActivity::class,
]
];
/**

View File

@ -1379,7 +1379,7 @@ $contact = ClientContact::factory()->create([
])->post('/api/v1/payments/bulk?action=delete', $data);
$arr = $response->json();
info(print_r($arr,1));
$this->assertEquals(1, $arr['data'][0]['is_deleted']);
}