2013-11-29 13:09:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class ActivityController extends \BaseController {
|
|
|
|
|
2013-12-04 17:20:14 +01:00
|
|
|
public function getDatatable($clientPublicId)
|
2013-11-29 13:09:21 +01:00
|
|
|
{
|
2013-12-30 21:17:45 +01:00
|
|
|
$query = DB::table('activities')
|
|
|
|
->join('clients', 'clients.id', '=', 'activities.client_id')
|
|
|
|
->where('clients.public_id', '=', $clientPublicId)
|
|
|
|
->where('activities.account_id', '=', Auth::user()->account_id)
|
|
|
|
->select('activities.message', 'activities.created_at', 'activities.currency_id', 'activities.balance', 'activities.adjustment');
|
2013-12-04 17:20:14 +01:00
|
|
|
|
2013-12-30 21:17:45 +01:00
|
|
|
return Datatable::query($query)
|
2014-01-08 00:59:06 +01:00
|
|
|
->addColumn('created_at', function($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); })
|
2014-01-08 21:09:47 +01:00
|
|
|
->addColumn('message', function($model) { return Utils::decodeActivity($model->message); })
|
2013-12-30 21:17:45 +01:00
|
|
|
->addColumn('balance', function($model) { return Utils::formatMoney($model->balance, $model->currency_id); })
|
|
|
|
->addColumn('adjustment', function($model) { return $model->adjustment != 0 ? Utils::formatMoney($model->adjustment, $model->currency_id) : ''; })
|
2013-11-29 13:09:21 +01:00
|
|
|
->make();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|