mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Added activities to API dashboard data
This commit is contained in:
parent
18d4cbcfbc
commit
2ebd40f46e
@ -3,11 +3,14 @@
|
||||
use Auth;
|
||||
use DB;
|
||||
use App\Ninja\Repositories\DashboardRepository;
|
||||
use App\Ninja\Transformers\ActivityTransformer;
|
||||
|
||||
class DashboardApiController extends BaseAPIController
|
||||
{
|
||||
public function __construct(DashboardRepository $dashboardRepo)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dashboardRepo = $dashboardRepo;
|
||||
}
|
||||
|
||||
@ -47,7 +50,7 @@ class DashboardApiController extends BaseAPIController
|
||||
'averageInvoiceCurrency' => $averageInvoice[0]->currency_id ? $averageInvoice[0]->currency_id : 0,
|
||||
'invoicesSent' => $metrics ? $metrics->invoices_sent : 0,
|
||||
'activeClients' => $metrics ? $metrics->active_clients : 0,
|
||||
//'activities' => $activities,
|
||||
'activities' => $this->createCollection($activities, new ActivityTransformer(), ENTITY_ACTIVITY),
|
||||
];
|
||||
|
||||
return $this->response($data);
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use stdClass;
|
||||
use Auth;
|
||||
use DB;
|
||||
use View;
|
||||
@ -46,6 +47,14 @@ class DashboardController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$data = $activities->map(function($item, $key) {
|
||||
$obj = new stdClass;
|
||||
$obj->client_id = $item->client->public_id;
|
||||
return $obj;
|
||||
});
|
||||
dd($data[0]);
|
||||
|
||||
|
||||
$data = [
|
||||
'account' => $user->account,
|
||||
'paidToDate' => $paidToDate,
|
||||
|
33
app/Ninja/Transformers/ActivityTransformer.php
Normal file
33
app/Ninja/Transformers/ActivityTransformer.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php namespace App\Ninja\Transformers;
|
||||
|
||||
use App\Models\Activity;
|
||||
|
||||
/**
|
||||
* @SWG\Definition(definition="Activity", @SWG\Xml(name="Activity"))
|
||||
*/
|
||||
|
||||
class ActivityTransformer extends EntityTransformer
|
||||
{
|
||||
protected $defaultIncludes = [ ];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [ ];
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Activity $activity)
|
||||
{
|
||||
return [
|
||||
'activity_type_id' => $activity->activity_type_id,
|
||||
'client_id' => $activity->client->public_id,
|
||||
'user_id' => $activity->user->public_id + 1,
|
||||
'invoice_id' => $activity->invoice ? $activity->invoice->public_id : null,
|
||||
'payment_id' => $activity->payment ? $activity->payment->public_id : null,
|
||||
'credit_id' => $activity->credit ? $activity->credit->public_id : null,
|
||||
];
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user