Menu

## PurchaseHistory extends Component
in package
uses HandlesGuzzleRequests, WithFileUploads

PurchaseHistory.php : 28

Class PurchaseHistory

Livewire component responsible for displaying the add-on purchase history for the authenticated user.

This component handles:

- Fetching paginated purchase history
- Displaying purchase details
- Uploading payment attachments
- Pagination navigation

### Table of Contents

#### Properties

$currentPage : int
  Current pagination page number.
$image : TemporaryUploadedFile|null
  Uploaded attachment image file.
$purchase_histories : array<string|int, mixed>|null
  Purchase history response data.
$purchase_history_id : int|string|null
  Selected purchase history identifier.
$show_attachment : bool
  Controls visibility of attachment upload modal.
$user : Authenticatable|null
  Authenticated user instance.

#### Methods

closeModal() : void
  Close the attachment upload modal.
getPurchaseHistory() : array<string|int, mixed>|null
  Fetch purchase history data from external API.
goToPage() : void
  Navigate to a specific pagination page.
guzzleImagePost() : ResponseInterface
  Perform a POST request that can send files using multipart/form-data.
mount() : void
  Lifecycle hook executed when the component is mounted.
openUploadModal() : void
  Open attachment upload modal for a specific purchase.
render() : View
  Render the Livewire component view.
uploadImage() : void
  Upload attachment image for a purchase history record.
guzzleGet() : array<string|int, mixed>|null
  Perform a GET request using Guzzle and return decoded JSON.
guzzlePost() : array<string|int, mixed>|null
  Perform a POST request using Guzzle and return decoded JSON.

### Properties

#### $currentPage

PurchaseHistory.php : 75

Current pagination page number.

`public int $currentPage = 1`

#### $image

PurchaseHistory.php : 61

Uploaded attachment image file.

`public TemporaryUploadedFile|null $image`

#### $purchase_histories

PurchaseHistory.php : 47

Purchase history response data.

`public array<string|int, mixed>|null $purchase_histories`

Contains list, pagination, and contact details.

#### $purchase_history_id

PurchaseHistory.php : 68

Selected purchase history identifier.

`public int|string|null $purchase_history_id`

#### $show_attachment

PurchaseHistory.php : 54

Controls visibility of attachment upload modal.

`public bool $show_attachment = false`

#### $user

PurchaseHistory.php : 38

Authenticated user instance.

`public Authenticatable|null $user`

### Methods

#### closeModal()

PurchaseHistory.php : 191

Close the attachment upload modal.

`public closeModal() : void`

#### getPurchaseHistory()

PurchaseHistory.php : 117

Fetch purchase history data from external API.

`public getPurchaseHistory(int $page) : array<string|int, mixed>|null`

##### Parameters

$page : int

  Current pagination page

##### Return values

array<string|int, mixed>|null

#### goToPage()

PurchaseHistory.php : 205

Navigate to a specific pagination page.

`public goToPage(int $page) : void`

Ensures the page number stays within valid bounds and refreshes the purchase history list.

##### Parameters

$page : int

#### guzzleImagePost()

HandlesGuzzleRequests.php : 79

Perform a POST request that can send files using multipart/form-data.

`public guzzleImagePost(string $url[, array<string|int, mixed> $data = [] ][, bool $hasFile = false ]) : ResponseInterface`

##### Parameters

$url : string

  Endpoint URL

$data : array<string|int, mixed> = []

  Form data or files

$hasFile : bool = false

  Whether the payload includes uploaded files

##### Return values

ResponseInterface

#### mount()

PurchaseHistory.php : 85

Lifecycle hook executed when the component is mounted.

`public mount() : void`

Initializes authenticated user and loads the first page of purchase history.

#### openUploadModal()

PurchaseHistory.php : 141

Open attachment upload modal for a specific purchase.

`public openUploadModal(int|string $purchase_history_id) : void`

##### Parameters

$purchase_history_id : int|string

#### render()

PurchaseHistory.php : 99

Render the Livewire component view.

`public render() : View`

Passes purchase history data and pagination details to the Blade view.

##### Return values

View

#### uploadImage()

PurchaseHistory.php : 155

Upload attachment image for a purchase history record.

`public uploadImage() : void`

Validates the uploaded file and sends it to the external API for storage.

#### guzzleGet()

HandlesGuzzleRequests.php : 16

Perform a GET request using Guzzle and return decoded JSON.

`protected guzzleGet(string $url[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>|null`

##### Parameters

$url : string

  Endpoint URL

$params : array<string|int, mixed> = []

  Query parameters

##### Return values

array<string|int, mixed>|null —

Decoded response or null on failure

#### guzzlePost()

HandlesGuzzleRequests.php : 46

Perform a POST request using Guzzle and return decoded JSON.

`protected guzzlePost(string $url[, array<string|int, mixed> $data = [] ][, bool $asJson = false ]) : array<string|int, mixed>|null`

##### Parameters

$url : string

  Endpoint URL

$data : array<string|int, mixed> = []

  Payload data

$asJson : bool = false

  When true sends JSON, otherwise form-params

##### Return values

array<string|int, mixed>|null —

Decoded response or null on failure

## Search results