mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-25 02:10:39 +00:00
show transaction usage history detail
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace Domain\Transactions\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Domain\Transactions\Resources\TransactionCollection;
|
||||
|
||||
class GetTransactionsController extends Controller
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
$transactions = Auth::user()
|
||||
->transactions()
|
||||
->sortable(['created_at' => 'desc'])
|
||||
->paginate(20);
|
||||
|
||||
return new TransactionCollection($transactions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Domain\Transactions\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class TransactionCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = TransactionResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace Domain\Transactions\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Users\Actions\FormatUsageEstimatesAction;
|
||||
|
||||
class TransactionResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
'type' => 'transactions',
|
||||
'attributes' => [
|
||||
'type' => $this->type,
|
||||
'status' => $this->status,
|
||||
'note' => $this->note,
|
||||
'price' => format_currency($this->amount, $this->currency),
|
||||
'currency' => $this->currency,
|
||||
'amount' => $this->amount,
|
||||
'driver' => $this->driver,
|
||||
'reference' => $this->reference,
|
||||
'metadata' => $this->metadata
|
||||
? resolve(FormatUsageEstimatesAction::class)($this->currency, $this->metadata)
|
||||
: null,
|
||||
'created_at' => $this->created_at->formatLocalized('%d. %b. %Y'),
|
||||
'updated_at' => $this->updated_at,
|
||||
],
|
||||
'relationships' => [
|
||||
$this->mergeWhen($this->user && $this->user->settings, fn () => [
|
||||
'user' => [
|
||||
'data' => [
|
||||
'id' => $this->user->id,
|
||||
'type' => 'users',
|
||||
'attributes' => [
|
||||
'avatar' => $this->user->settings->avatar,
|
||||
'first_name' => $this->user->settings->first_name,
|
||||
'last_name' => $this->user->settings->last_name,
|
||||
'name' => $this->user->settings->name,
|
||||
'color' => $this->user->settings->color,
|
||||
'email' => $this->user->email,
|
||||
],
|
||||
],
|
||||
],
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user