Documentation

PelangganService uses HasResource

Class PelangganService

Provides services related to Pelanggan management.

Table of Contents

Properties

$model  : Model

Methods

__construct()  : mixed
all()  : Collection
Retrieve all records for the authenticated user, with optional search.
countActive()  : int
Count active Pelanggan for the authenticated user.
countAll()  : int
Count all Pelanggan for the authenticated user.
countCustomerByMonth()  : int
Count customers by month and year.
countNotPaidBills()  : float
Count not paid bills for Pelanggan for the current month and year.
countPaidBills()  : float
Count paid bills for Pelanggan for the current month and year.
countPaymentDue()  : int
Count Pelanggan with payment due.
countSuspended()  : int
Count suspended Pelanggan for the authenticated user.
countTerminated()  : int
Count terminated Pelanggan for the authenticated user.
countTrial()  : int
Count trial Pelanggan for the authenticated user.
create()  : Model
Create a new record with the given data.
customSearchQuery()  : Builder
Custom search query for Pelanggan, Paket, and Bills relationships.
delete()  : bool
Delete a record by ID.
find()  : Model|null
Find a record by ID for the authenticated user.
findBy()  : Model|null
Find a record by a specific field and value.
getBills()  : Collection
Get bills for a given Pelanggan.
getBy()  : Collection
Get records by a specific field and value.
getPaket()  : Collection
Get Paket records for the authenticated user.
getSelectedIds()  : array<string|int, mixed>
Get selected Pelanggan IDs based on search and filters.
paginate()  : LengthAwarePaginator
Paginate the Pelanggan records with optional search, filters, and sorting.
query()  : Builder
Get a new query builder instance for the model.
update()  : Model|null
Update a record by ID with the given data.
applyFilters()  : Builder
Apply filters to the query based on the provided filters array.
applyOrder()  : Builder
Apply sorting to the query based on the provided sort array.

Properties

Methods

all()

Retrieve all records for the authenticated user, with optional search.

public all([array<string|int, mixed> $search = [] ]) : Collection
Parameters
$search : array<string|int, mixed> = []

Search options.

Return values
Collection

The collection of records.

countActive()

Count active Pelanggan for the authenticated user.

public countActive() : int
Return values
int

The count of active Pelanggan.

countAll()

Count all Pelanggan for the authenticated user.

public countAll() : int
Return values
int

The total count.

countCustomerByMonth()

Count customers by month and year.

public countCustomerByMonth(int $month, int $year) : int
Parameters
$month : int

The month to filter by.

$year : int

The year to filter by.

Return values
int

The count of customers for the given month and year.

countNotPaidBills()

Count not paid bills for Pelanggan for the current month and year.

public countNotPaidBills() : float
Return values
float

The sum of not paid bills.

countPaidBills()

Count paid bills for Pelanggan for the current month and year.

public countPaidBills() : float
Return values
float

The sum of paid bills.

countPaymentDue()

Count Pelanggan with payment due.

public countPaymentDue() : int
Return values
int

The count of Pelanggan with payment due.

countSuspended()

Count suspended Pelanggan for the authenticated user.

public countSuspended() : int
Return values
int

The count of suspended Pelanggan.

countTerminated()

Count terminated Pelanggan for the authenticated user.

public countTerminated() : int
Return values
int

The count of terminated Pelanggan.

countTrial()

Count trial Pelanggan for the authenticated user.

public countTrial() : int
Return values
int

The count of trial Pelanggan.

create()

Create a new record with the given data.

public create(array<string|int, mixed> $data) : Model
Parameters
$data : array<string|int, mixed>

The data for the new record.

Return values
Model

The created model.

customSearchQuery()

Custom search query for Pelanggan, Paket, and Bills relationships.

public static customSearchQuery(Builder $builder[, string $search = '' ]) : Builder
Parameters
$builder : Builder

The Eloquent query builder.

$search : string = ''

The search string.

Return values
Builder

The modified query builder.

delete()

Delete a record by ID.

public delete(int $id) : bool
Parameters
$id : int

The record ID.

Return values
bool

True if deleted, false otherwise.

find()

Find a record by ID for the authenticated user.

public find(int $id) : Model|null
Parameters
$id : int

The record ID.

Return values
Model|null

The found model or null.

findBy()

Find a record by a specific field and value.

public findBy(string $field, mixed $value) : Model|null
Parameters
$field : string

The field name.

$value : mixed

The value to search for.

Return values
Model|null

The found model or null.

getBills()

Get bills for a given Pelanggan.

public getBills(Pelanggan $pelanggan) : Collection
Parameters
$pelanggan : Pelanggan

The Pelanggan instance.

Return values
Collection

The collection of Bill records.

getBy()

Get records by a specific field and value.

public getBy(string $field, mixed $value) : Collection
Parameters
$field : string

The field name.

$value : mixed

The value to search for.

Return values
Collection

The collection of records.

getPaket()

Get Paket records for the authenticated user.

public getPaket() : Collection
Return values
Collection

The collection of Paket records.

getSelectedIds()

Get selected Pelanggan IDs based on search and filters.

public getSelectedIds([array<string|int, mixed> $search = [] ][, array<string|int, mixed> $filters = [] ]) : array<string|int, mixed>
Parameters
$search : array<string|int, mixed> = []

Search options.

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

Filter options.

Return values
array<string|int, mixed>

Array of selected IDs.

paginate()

Paginate the Pelanggan records with optional search, filters, and sorting.

public paginate([int $perPage = 15 ][, array<string|int, mixed> $search = [] ][, array<string|int, mixed> $filters = [] ][, array<string|int, mixed> $sort = [] ]) : LengthAwarePaginator
Parameters
$perPage : int = 15

Number of records per page.

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

Search options.

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

Filter options.

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

Sort options.

Return values
LengthAwarePaginator

Paginated result set.

query()

Get a new query builder instance for the model.

public query() : Builder
Return values
Builder

The query builder instance.

update()

Update a record by ID with the given data.

public update(int $id, array<string|int, mixed> $data) : Model|null
Parameters
$id : int

The record ID.

$data : array<string|int, mixed>

The data to update.

Return values
Model|null

The updated model or null.

applyFilters()

Apply filters to the query based on the provided filters array.

private applyFilters(Builder $query, array<string|int, mixed> $filters) : Builder
Parameters
$query : Builder

The Eloquent query builder.

$filters : array<string|int, mixed>

The filters to apply.

Return values
Builder

The filtered query builder.

applyOrder()

Apply sorting to the query based on the provided sort array.

private applyOrder(Builder $query, array<string|int, mixed> $sort) : Builder
Parameters
$query : Builder

The Eloquent query builder.

$sort : array<string|int, mixed>

The sorting options.

Return values
Builder

The sorted query builder.


        
On this page

Search results