PHP 클래스 Overtrue\LaravelShoppingCart\Cart

파일 보기 프로젝트 열기: overtrue/laravel-shopping-cart

보호된 프로퍼티들

프로퍼티 타입 설명
$event Illuminate\Contracts\Events\Dispatcher Event dispatcher.
$model string Associated model name.
$name string Current cart name.
$session Illuminate\Session\SessionManager Session manager.

공개 메소드들

메소드 설명
__construct ( Illuminate\Session\SessionManager $session, Illuminate\Contracts\Events\Dispatcher $event ) Constructor.
add ( integer | string $id, string $name = null, integer $qty = null, float $price = null, array $attributes = [] ) : string Add a row to the cart.
all ( ) : Collection Get all items.
associate ( string $model ) : Cart Associated model.
clean ( ) : boolean Alias of destory().
count ( boolean $totalItems = true ) : integer Get the number of items in the cart.
countRows ( ) : integer Get rows count.
destroy ( ) : boolean Clean the cart.
get ( string $rawId ) : Item Get a row of the cart by its ID.
getModel ( ) : string Get current associated model.
getName ( ) : string Get current cart name.
isEmpty ( ) : boolean Return whether the shopping cart is empty.
name ( string $name ) : Cart Set the current cart name.
remove ( string $rawId ) : boolean Remove a row from the cart.
search ( array $search ) : array Search if the cart has a item.
total ( ) : float Get the price total.
totalPrice ( ) Return total price of cart.
update ( string $rawId, integer | array $attribute ) : Item | boolean Update the quantity of one row of the cart.

보호된 메소드들

메소드 설명
addRow ( string $id, string $name, integer $qty, float $price, array $attributes = [] ) : string Add row to the cart.
generateRawId ( string $id, array $attributes ) : string Generate a unique id for the new row.
getCart ( ) : Collection Get the carts content.
insertRow ( string $rawId, string $id, string $name, integer $qty, float $price, array $attributes = [] ) : Item Create a new row Object.
makeRow ( string $rawId, mixed $id, string $name, integer $qty, float $price, array $attributes = [] ) : Item Make a row item.
save ( Collection | null $cart ) : Collection Sync the cart to session.
updateAttribute ( string $rawId, array $attributes ) : Item Update an attribute of the row.
updateQty ( string $rawId, integer $qty ) : Item | boolean Update the quantity of a row.
updateRow ( string $rawId, array $attributes ) : Item Update a row if the rawId already exists.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( Illuminate\Session\SessionManager $session, Illuminate\Contracts\Events\Dispatcher $event )
$session Illuminate\Session\SessionManager Session class name
$event Illuminate\Contracts\Events\Dispatcher Event class name

add() 공개 메소드

Add a row to the cart.
public add ( integer | string $id, string $name = null, integer $qty = null, float $price = null, array $attributes = [] ) : string
$id integer | string Unique ID of the item
$name string Name of the item
$qty integer Item qty to add to the cart
$price float Price of one item
$attributes array Array of additional attributes, such as 'size' or 'color'...
리턴 string

addRow() 보호된 메소드

Add row to the cart.
protected addRow ( string $id, string $name, integer $qty, float $price, array $attributes = [] ) : string
$id string Unique ID of the item
$name string Name of the item
$qty integer Item qty to add to the cart
$price float Price of one item
$attributes array Array of additional options, such as 'size' or 'color'
리턴 string

all() 공개 메소드

Get all items.
public all ( ) : Collection
리턴 Illuminate\Support\Collection

associate() 공개 메소드

Associated model.
public associate ( string $model ) : Cart
$model string The name of the model
리턴 Cart

clean() 공개 메소드

Alias of destory().
public clean ( ) : boolean
리턴 boolean

count() 공개 메소드

Get the number of items in the cart.
public count ( boolean $totalItems = true ) : integer
$totalItems boolean Get all the items (when false, will return the number of rows)
리턴 integer

countRows() 공개 메소드

Get rows count.
public countRows ( ) : integer
리턴 integer

destroy() 공개 메소드

Clean the cart.
public destroy ( ) : boolean
리턴 boolean

generateRawId() 보호된 메소드

Generate a unique id for the new row.
protected generateRawId ( string $id, array $attributes ) : string
$id string Unique ID of the item
$attributes array Array of additional options, such as 'size' or 'color'
리턴 string

get() 공개 메소드

Get a row of the cart by its ID.
public get ( string $rawId ) : Item
$rawId string The ID of the row to fetch
리턴 Item

getCart() 보호된 메소드

Get the carts content.
protected getCart ( ) : Collection
리턴 Illuminate\Support\Collection

getModel() 공개 메소드

Get current associated model.
public getModel ( ) : string
리턴 string

getName() 공개 메소드

Get current cart name.
public getName ( ) : string
리턴 string

insertRow() 보호된 메소드

Create a new row Object.
protected insertRow ( string $rawId, string $id, string $name, integer $qty, float $price, array $attributes = [] ) : Item
$rawId string The ID of the new row
$id string Unique ID of the item
$name string Name of the item
$qty integer Item qty to add to the cart
$price float Price of one item
$attributes array Array of additional options, such as 'size' or 'color'
리턴 Item

isEmpty() 공개 메소드

Return whether the shopping cart is empty.
public isEmpty ( ) : boolean
리턴 boolean

makeRow() 보호된 메소드

Make a row item.
protected makeRow ( string $rawId, mixed $id, string $name, integer $qty, float $price, array $attributes = [] ) : Item
$rawId string Raw id.
$id mixed Item id.
$name string Item name.
$qty integer Quantity.
$price float Price.
$attributes array Other attributes.
리턴 Item

name() 공개 메소드

Set the current cart name.
public name ( string $name ) : Cart
$name string Cart name name
리턴 Cart

remove() 공개 메소드

Remove a row from the cart.
public remove ( string $rawId ) : boolean
$rawId string The __raw_id of the item
리턴 boolean

save() 보호된 메소드

Sync the cart to session.
protected save ( Collection | null $cart ) : Collection
$cart Illuminate\Support\Collection | null The new cart content
리턴 Illuminate\Support\Collection

total() 공개 메소드

Get the price total.
public total ( ) : float
리턴 float

totalPrice() 공개 메소드

Return total price of cart.
public totalPrice ( )

update() 공개 메소드

Update the quantity of one row of the cart.
public update ( string $rawId, integer | array $attribute ) : Item | boolean
$rawId string The __raw_id of the item you want to update
$attribute integer | array New quantity of the item|Array of attributes to update
리턴 Item | boolean

updateAttribute() 보호된 메소드

Update an attribute of the row.
protected updateAttribute ( string $rawId, array $attributes ) : Item
$rawId string The ID of the row
$attributes array An array of attributes to update
리턴 Item

updateQty() 보호된 메소드

Update the quantity of a row.
protected updateQty ( string $rawId, integer $qty ) : Item | boolean
$rawId string The ID of the row
$qty integer The qty to add
리턴 Item | boolean

updateRow() 보호된 메소드

Update a row if the rawId already exists.
protected updateRow ( string $rawId, array $attributes ) : Item
$rawId string The ID of the row to update
$attributes array The quantity to add to the row
리턴 Item

프로퍼티 상세

$event 보호되어 있는 프로퍼티

Event dispatcher.
protected Dispatcher,Illuminate\Contracts\Events $event
리턴 Illuminate\Contracts\Events\Dispatcher

$model 보호되어 있는 프로퍼티

Associated model name.
protected string $model
리턴 string

$name 보호되어 있는 프로퍼티

Current cart name.
protected string $name
리턴 string

$session 보호되어 있는 프로퍼티

Session manager.
protected SessionManager,Illuminate\Session $session
리턴 Illuminate\Session\SessionManager