idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
50,800
private function curl ( $ query_string ) { $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ query_string ) ; curl_setopt ( $ curl , CURLOPT_VERBOSE , 1 ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYHOST , 2 ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYPEER , 1 ) ; curl_setopt ( $ curl , CURLOPT_CAI...
Curl is responsible for sending data to remote server using certificate for ssl connection
50,801
private function parse_result ( $ string ) { $ array1 = explode ( PHP_EOL , trim ( $ string ) ) ; $ result = array ( ) ; foreach ( $ array1 as $ key => $ value ) { $ array2 = explode ( ':' , $ value ) ; $ result [ $ array2 [ 0 ] ] = trim ( $ array2 [ 1 ] ) ; } return $ result ; }
Parse tbcbank server response string into an array
50,802
private function process ( $ post_fields ) { $ string = $ this -> build_query_string ( $ post_fields ) ; $ result = $ this -> curl ( $ string ) ; $ parsed = $ this -> parse_result ( $ result ) ; return $ parsed ; }
Takes array and transforms into a POST string curls it to tbc server parses results returns parsed results
50,803
public function dms_start_authorization ( ) { $ post_fields = array ( 'command' => 'a' , 'amount' => $ this -> amount , 'currency' => $ this -> currency , 'client_ip_addr' => $ this -> client_ip_addr , 'description' => $ this -> description , 'language' => $ this -> language , 'biller' => $ this -> biller , 'msg_type' ...
Registering DMS authorization DMS is different from SMS dms_start_authorization blocks amount and than we use dms_make_transaction to charge customer .
50,804
public function dms_make_transaction ( $ trans_id ) { $ post_fields = array ( 'command' => 't' , 'trans_id' => $ trans_id , 'amount' => $ this -> amount , 'currency' => $ this -> currency , 'client_ip_addr' => $ this -> client_ip_addr , 'description' => $ this -> description , 'language' => $ this -> language , 'msg_ty...
Executing a DMS transaction
50,805
public function setBody ( \ GoetasWebservices \ SoapServices \ SoapClient \ Envelope \ SoapEnvelope12 \ Messages \ FaultBody $ body ) { $ this -> body = $ body ; return $ this ; }
Sets a new body
50,806
public function dispatch ( Controller $ obj_controller ) { $ obj_controller -> preDispatch ( ) ; $ obj_controller -> dispatch ( ) ; $ obj_controller -> postDispatch ( ) ; $ this -> sendResponse ( $ obj_controller -> getResponse ( ) ) ; }
Go Johnny Go!
50,807
public function timeToDie ( ) { $ arr_error = error_get_last ( ) ; if ( $ arr_error && in_array ( $ arr_error [ 'type' ] , [ E_ERROR , E_USER_ERROR , E_COMPILE_ERROR ] ) ) { $ this -> jsonError ( new \ ErrorException ( $ arr_error [ 'message' ] , 500 , 0 , $ arr_error [ 'file' ] , $ arr_error [ 'line' ] ) , 500 ) ; } }
Custom shutdown function
50,808
protected function jsonError ( \ Exception $ obj_error , $ int_code ) { $ arr_response = [ 'code' => $ int_code , 'msg' => ( $ obj_error instanceof \ ErrorException ? 'Internal Error' : 'Exception' ) ] ; $ str_log_message = get_class ( $ obj_error ) . ': ' . $ obj_error -> getMessage ( ) ; if ( $ this -> bol_expose_err...
Whatever went wrong let em have it in JSON over HTTP
50,809
protected function sendResponse ( $ response , $ http_code = 200 ) { $ http_code = min ( max ( $ http_code , 100 ) , 505 ) ; http_response_code ( $ http_code ) ; header ( 'Content-type: application/json' ) ; echo json_encode ( $ response ) ; }
Output the response as JSON with HTTP headers
50,810
protected function routeStatic ( ) { if ( isset ( $ this -> arr_static_routes [ $ this -> arr_url [ 'path' ] ] ) ) { $ this -> setup ( $ this -> arr_static_routes [ $ this -> arr_url [ 'path' ] ] , NULL , FALSE ) ; return TRUE ; } return FALSE ; }
Check for static routes setup if needed
50,811
protected function setup ( $ str_controller , $ bol_parse = TRUE ) { $ this -> str_controller = ( $ bol_parse ? $ this -> parseController ( $ str_controller ) : $ str_controller ) ; if ( ! method_exists ( $ this -> str_controller , 'dispatch' ) ) { throw new Routing ( "Could not find controller: {$this->str_controller}...
Check & store controller from URL parts
50,812
protected function getHeaders ( ) { if ( function_exists ( 'getallheaders' ) ) { return getallheaders ( ) ; } $ arr_headers = [ ] ; foreach ( $ _SERVER as $ str_key => $ str_value ) { if ( strpos ( $ str_key , 'HTTP_' ) === 0 ) { $ arr_headers [ str_replace ( ' ' , '-' , ucwords ( strtolower ( str_replace ( '_' , ' ' ,...
Get the HTTP request headers
50,813
protected function getJson ( ) { if ( $ this -> str_request_body_json === null ) { $ this -> str_request_body_json = json_decode ( $ this -> getBody ( ) ) ; } return $ this -> str_request_body_json ; }
Get the request body as a JSON object
50,814
protected function getParam ( $ str_key , $ str_default = null , $ check_json_body = false ) { $ str_query = $ this -> getQuery ( $ str_key ) ; if ( null !== $ str_query ) { return $ str_query ; } $ str_post = $ this -> getPost ( $ str_key ) ; if ( NULL !== $ str_post ) { return $ str_post ; } if ( $ check_json_body &&...
Get a request parameter . Check GET then POST data then optionally any json body data .
50,815
protected function getPost ( $ str_key , $ str_default = NULL ) { return ( isset ( $ _POST [ $ str_key ] ) ? $ _POST [ $ str_key ] : $ str_default ) ; }
Get a POST parameter
50,816
public static function convert ( $ string ) { $ sign = "(?P<sign>[-\+])?" ; $ digits = "(?P<digits>\d*)" ; $ separator = "(?P<separator>[.,])?" ; $ decimals = "(?P<decimal1>\d)?(?P<decimal2>\d)?(?P<remaining_decimals>\d)*" ; $ pattern = "/^" . $ sign . $ digits . $ separator . $ decimals . "$/" ; if ( ! preg_match ( $ ...
Converts a string value with an amount into an integer . Supports up to 5 decimals points .
50,817
public function repository ( $ name = null ) { $ name = $ name ? : $ this -> getDefaultDriver ( ) ; return $ this -> repositories [ $ name ] = $ this -> get ( $ name ) ; }
Get a setting repository instance by name .
50,818
protected function get ( $ name ) { return isset ( $ this -> repositories [ $ name ] ) ? $ this -> repositories [ $ name ] : $ this -> resolve ( $ name ) ; }
Attempt to get the repository from the local cache .
50,819
protected function createDatabaseDriver ( array $ config ) { return new DatabaseRepository ( $ this -> app [ 'db' ] -> connection ( Arr :: get ( $ config , 'connection' ) ) , Arr :: get ( $ config , 'table' ) ) ; }
Create database repository .
50,820
public function has ( $ key ) { $ this -> fire ( 'checking' , $ key , [ $ key ] ) ; $ status = $ this -> repository -> has ( $ this -> getKey ( $ key ) ) ; $ this -> fire ( 'has' , $ key , [ $ key , $ status ] ) ; $ this -> context ( null ) ; return $ status ; }
Determine if the given setting value exists .
50,821
public function get ( $ key , $ default = null ) { $ this -> fire ( 'getting' , $ key , [ $ key , $ default ] ) ; $ generatedKey = $ this -> getKey ( $ key ) ; if ( $ this -> isCacheEnabled ( ) ) { $ repository = $ this -> repository ; $ value = $ this -> cache -> rememberForever ( $ generatedKey , function ( ) use ( $...
Get the specified setting value .
50,822
public function forget ( $ key ) { $ this -> fire ( 'forgetting' , $ key , [ $ key ] ) ; $ generatedKey = $ this -> getKey ( $ key ) ; $ this -> repository -> forget ( $ generatedKey ) ; if ( $ this -> isCacheEnabled ( ) ) { $ this -> cache -> forget ( $ generatedKey ) ; } $ this -> fire ( 'forget' , $ key , [ $ key ] ...
Forget current setting value .
50,823
protected function fire ( $ event , $ key , array $ payload = [ ] ) { $ payload [ ] = $ this -> context ; if ( $ this -> isEventsEnabled ( ) ) { $ this -> dispatcher -> fire ( "settings.{$event}: {$key}" , $ payload ) ; } }
Fire settings event .
50,824
public function get ( $ name ) { if ( ! isset ( $ this -> arguments [ $ name ] ) ) { throw new \ OutOfBoundsException ( sprintf ( '"%s" is not part of context.' , $ name ) ) ; } return $ this -> arguments [ $ name ] ; }
Access context argument value .
50,825
public function generate ( $ key , Context $ context = null ) { return md5 ( $ key . $ this -> serializer -> serialize ( $ context ) ) ; }
Generate storage key for a given key and context .
50,826
protected function overrideConfig ( array $ override , Repository $ config , Settings $ settings , Dispatcher $ dispatcher ) { foreach ( $ override as $ key => $ settingKey ) { $ configKey = is_string ( $ key ) ? $ key : $ settingKey ; $ dispatcher -> fire ( "settings.overriding: {$configKey}" , [ $ configKey , $ setti...
Override give config values from persistent setting storage .
50,827
protected function registerCommands ( ) { $ this -> app -> singleton ( 'command.settings.table' , function ( $ app ) { return new SettingsTableCommand ( $ app [ 'files' ] , $ app [ 'composer' ] ) ; } ) ; $ this -> commands ( 'command.settings.table' ) ; }
Register the settings related console commands .
50,828
public function getStateName ( $ lookFor , $ country = null ) { if ( $ country ) { if ( ! isset ( $ this -> states [ $ country ] ) ) { $ this -> findCountryStates ( $ country ) ; } if ( isset ( $ this -> states [ $ country ] [ $ lookFor ] ) ) { return $ this -> states [ $ country ] [ $ lookFor ] ; } throw new Exception...
Get the name of a state by passing its two character code Specifying a two character ISO country code will limit the search to a specific country
50,829
public function setLanguage ( $ language ) { $ this -> language = $ language ; foreach ( $ this -> countries as $ country ) { $ this -> countriesTranslated [ $ country -> getIsoAlpha2 ( ) ] = $ country -> getTranslation ( $ this -> language ) [ 'common' ] ; } return $ this ; }
Change the default translation language using the three character ISO 639 - 3 code of the desired language . Country name translations will be reloaded .
50,830
public function applyDiscount ( $ percentage , $ couponId = null ) { if ( $ percentage > 100 ) { throw new IncorrectDiscount ( 'Maximum percentage discount can be 100%.' ) ; } if ( $ this -> subtotal == 0 ) { throw new IncorrectDiscount ( 'Discount cannot be applied on an empty cart.' ) ; } $ this -> discountPercentage...
Applies disount to the cart .
50,831
public function applyFlatDiscount ( $ amount , $ couponId = null ) { if ( $ amount > $ this -> subtotal ) { throw new IncorrectDiscount ( 'The discount amount cannot be more that subtotal of the cart' ) ; } $ this -> discount = round ( $ amount , 2 ) ; $ this -> discountPercentage = 0 ; $ this -> couponId = $ couponId ...
Applies flat disount to the cart .
50,832
public function add ( $ entity , $ quantity ) { if ( $ this -> itemExists ( $ entity ) ) { $ cartItemIndex = $ this -> items -> search ( $ this -> cartItemsCheck ( $ entity ) ) ; return $ this -> incrementQuantityAt ( $ cartItemIndex , $ quantity ) ; } $ this -> items -> push ( CartItem :: createFrom ( $ entity , $ qua...
Adds an item to the cart .
50,833
protected function cartItemsCheck ( $ entity ) { return function ( $ item ) use ( $ entity ) { return $ item -> modelType == get_class ( $ entity ) && $ item -> modelId == $ entity -> { $ entity -> getKeyName ( ) } ; } ; }
Checks if a cart item with the specified entity already exists .
50,834
public function removeAt ( $ cartItemIndex ) { $ this -> existenceCheckFor ( $ cartItemIndex ) ; $ item = $ this -> items [ $ cartItemIndex ] ; $ this -> cartDriver -> removeCartItem ( $ item -> id ) ; $ this -> items = $ this -> items -> forget ( $ cartItemIndex ) -> values ( ) ; $ modelType = $ item -> modelType ; $ ...
Removes an item from the cart .
50,835
public function incrementQuantityAt ( $ cartItemIndex , $ quantity = 1 ) { $ this -> existenceCheckFor ( $ cartItemIndex ) ; $ this -> items [ $ cartItemIndex ] -> quantity += $ quantity ; $ this -> cartDriver -> setCartItemQuantity ( $ this -> items [ $ cartItemIndex ] -> id , $ this -> items [ $ cartItemIndex ] -> qu...
Increments the quantity of a cart item .
50,836
public function decrementQuantityAt ( $ cartItemIndex , $ quantity = 1 ) { $ this -> existenceCheckFor ( $ cartItemIndex ) ; if ( $ this -> items [ $ cartItemIndex ] -> quantity <= $ quantity ) { return $ this -> removeAt ( $ cartItemIndex ) ; } $ this -> items [ $ cartItemIndex ] -> quantity -= $ quantity ; $ this -> ...
Decrements the quantity of a cart item .
50,837
public function refreshAllItemsData ( ) { $ keepDiscount = true ; $ this -> items -> transform ( function ( $ item ) use ( & $ keepDiscount ) { $ freshEntity = $ item -> modelType :: findOrFail ( $ item -> modelId ) ; $ cartItem = CartItem :: createFrom ( $ freshEntity , $ item -> quantity ) ; if ( $ cartItem -> price ...
Refreshes all items data .
50,838
protected function setProperties ( $ attributes ) { foreach ( $ attributes as $ key => $ value ) { $ this -> { camel_case ( $ key ) } = $ value ; } }
Sets the object properties from the provided data .
50,839
protected function setItems ( $ cartItems ) { foreach ( $ cartItems as $ cartItem ) { $ this -> items -> push ( CartItem :: createFrom ( $ cartItem ) ) ; } }
Creates CartItem objects from the data .
50,840
protected function cartUpdates ( $ isNewItem = false , $ keepDiscount = false ) { $ this -> updateTotals ( $ keepDiscount ) ; $ this -> storeCartData ( $ isNewItem ) ; return $ this -> toArray ( ) ; }
Performs cart updates and returns the data .
50,841
protected function storeCartData ( $ isNewItem = false ) { if ( $ this -> id ) { $ this -> cartDriver -> updateCart ( $ this -> id , $ this -> data ( ) ) ; if ( $ isNewItem ) { $ this -> cartDriver -> addCartItem ( $ this -> id , $ this -> items -> last ( ) -> toArray ( ) ) ; } return ; } event ( new CartCreated ( $ th...
Stores the cart data on the cart driver .
50,842
public function items ( $ displayCurrency = false ) { $ items = $ this -> items -> map -> toArray ( ) ; if ( ! $ displayCurrency ) { return $ items -> toArray ( ) ; } setlocale ( LC_MONETARY , config ( 'cart_manager.LC_MONETARY' ) ) ; return $ items -> map ( function ( $ item ) { $ item [ 'price' ] = money_format ( '%n...
Returns the cart items .
50,843
public function totals ( ) { setlocale ( LC_MONETARY , config ( 'cart_manager.LC_MONETARY' ) ) ; $ totals = [ 'Subtotal' => money_format ( '%n' , $ this -> subtotal ) ] ; if ( $ this -> discount > 0 ) { $ totals [ 'Discount' ] = money_format ( '%n' , $ this -> discount ) ; } if ( $ this -> shippingCharges > 0 ) { $ tot...
Returns the cart totals with currency .
50,844
public function storeNewCartData ( $ cartData ) { foreach ( $ cartData [ 'items' ] as $ key => $ item ) { $ cartData [ 'items' ] [ $ key ] [ 'id' ] = $ key + 1 ; } session ( [ $ this -> sessionKey => array_merge ( $ cartData , [ 'id' => 1 ] ) , ] ) ; }
Stores the cart and cart items data .
50,845
public function addCartItem ( $ cartId , $ cartItem ) { $ cartItem [ 'id' ] = count ( session ( $ this -> itemsKey ) ) + 1 ; session ( ) -> push ( $ this -> itemsKey , $ cartItem ) ; }
Adds a new cart item to the cart .
50,846
public function removeCartItem ( $ cartItemId ) { $ items = collect ( session ( $ this -> itemsKey ) ) ; $ items = $ items -> reject ( function ( $ item ) use ( $ cartItemId ) { return $ item [ 'id' ] == $ cartItemId ; } ) ; session ( [ $ this -> itemsKey => $ items ] ) ; }
Removes a cart item from the cart .
50,847
public function setCartItemQuantity ( $ cartItemId , $ newQuantity ) { $ items = collect ( session ( $ this -> itemsKey ) ) ; $ items = $ items -> map ( function ( $ item ) use ( $ cartItemId , $ newQuantity ) { if ( $ item [ 'id' ] == $ cartItemId ) { $ item [ 'quantity' ] = $ newQuantity ; } return $ item ; } ) ; ses...
Updates the quantity of the cart item .
50,848
protected function createFromModel ( $ entity , $ quantity ) { $ this -> modelType = get_class ( $ entity ) ; $ this -> modelId = $ entity -> { $ entity -> getKeyName ( ) } ; $ this -> setName ( $ entity ) ; $ this -> setPrice ( $ entity ) ; $ this -> setImage ( $ entity ) ; $ this -> quantity = $ quantity ; return $ t...
Creates a new cart item from a model instance .
50,849
protected function createFromArray ( $ array ) { $ this -> id = $ array [ 'id' ] ; $ this -> modelType = $ array [ 'modelType' ] ; $ this -> modelId = $ array [ 'modelId' ] ; $ this -> name = $ array [ 'name' ] ; $ this -> price = $ array [ 'price' ] ; $ this -> image = $ array [ 'image' ] ; $ this -> quantity = $ arra...
Creates a new cart item from an array .
50,850
protected function setName ( $ entity ) { if ( method_exists ( $ entity , 'getName' ) ) { $ this -> name = $ entity -> getName ( ) ; return ; } if ( $ entity -> offsetExists ( 'name' ) ) { $ this -> name = $ entity -> name ; return ; } throw ItemNameMissing :: for ( $ this -> modelType ) ; }
Sets the name of the item .
50,851
protected function setPrice ( $ entity ) { if ( method_exists ( $ entity , 'getPrice' ) ) { $ this -> price = $ entity -> getPrice ( ) ; return ; } if ( $ entity -> offsetExists ( 'price' ) ) { $ this -> price = $ entity -> price ; return ; } throw ItemPriceMissing :: for ( $ this -> modelType ) ; }
Sets the price of the item .
50,852
protected function setImage ( $ entity ) { if ( method_exists ( $ entity , 'getImage' ) ) { $ this -> image = $ entity -> getImage ( ) ; return ; } if ( isset ( $ entity -> image ) ) { $ this -> image = $ entity -> image ; } }
Sets the image of the item .
50,853
public function boot ( ) { if ( $ this -> app -> runningInConsole ( ) ) { $ this -> publishes ( [ __DIR__ . '/../config/cart_manager.php' => config_path ( 'cart_manager.php' ) , ] , 'laravel-cart-manager-config' ) ; $ this -> publishes ( [ __DIR__ . '/../database/migrations/' => database_path ( 'migrations' ) , ] , 'la...
Publishes configuration file and registers error handler for Slack notification .
50,854
public function register ( ) { $ this -> mergeConfigFrom ( __DIR__ . '/../config/cart_manager.php' , 'cart_manager' ) ; $ this -> app -> bind ( CartDriver :: class , $ this -> app [ 'config' ] [ 'cart_manager' ] [ 'driver' ] ) ; $ this -> app -> bind ( Cart :: class , function ( $ app ) { return new Cart ( $ app -> mak...
Service container bindings .
50,855
protected function updateTotals ( $ keepDiscount = false ) { $ this -> setSubtotal ( ) ; if ( ! $ keepDiscount ) { $ this -> discount = $ this -> discountPercentage = 0 ; $ this -> couponId = null ; } $ this -> setShippingCharges ( ) ; $ this -> netTotal = round ( $ this -> subtotal - $ this -> discount + $ this -> shi...
Sets the total variables of the object .
50,856
protected function setSubtotal ( ) { $ this -> subtotal = round ( $ this -> items -> sum ( function ( $ cartItem ) { return $ cartItem -> price * $ cartItem -> quantity ; } ) , 2 ) ; }
Sets the subtotal of the cart .
50,857
protected function setShippingCharges ( ) { $ this -> shippingCharges = 0 ; $ orderAmount = $ this -> subtotal - $ this -> discount ; if ( $ orderAmount > 0 && $ orderAmount < config ( 'cart_manager.shipping_charges_threshold' ) ) { $ shippingCharges = config ( 'cart_manager.shipping_charges' ) ; if ( $ shippingCharges...
Sets the shipping charges of the cart .
50,858
protected function setPayableAndRoundOff ( ) { switch ( config ( 'cart_manager.round_off_to' ) ) { case 0.05 : $ this -> payable = round ( $ this -> total * 2 , 1 ) / 2 ; break ; case 0.1 : $ this -> payable = round ( $ this -> total , 1 ) ; break ; case 0.5 : $ this -> payable = round ( $ this -> total * 2 ) / 2 ; bre...
Sets the payable and round off amount of the cart .
50,859
public function toArray ( ) { return [ 'id' => $ this -> id , 'modelType' => $ this -> model_type , 'modelId' => $ this -> model_id , 'name' => $ this -> name , 'price' => $ this -> price , 'image' => $ this -> image , 'quantity' => $ this -> quantity , ] ; }
This method is put to convert snake case in camelCase .
50,860
public function getCartData ( ) { $ selectColumns = [ 'id' , 'subtotal' , 'discount' , 'discount_percentage' , 'coupon_id' , 'shipping_charges' , 'net_total' , 'tax' , 'total' , 'round_off' , 'payable' ] ; $ cartData = Cart :: with ( $ this -> cartItemsQuery ( ) ) -> where ( $ this -> cartIdentifier ( ) ) -> first ( $ ...
Returns current cart data .
50,861
protected function assignCustomerToCartRecord ( ) { Cart :: where ( $ this -> getCookieElement ( ) ) -> update ( [ 'auth_user' => Auth :: guard ( config ( 'cart_manager.auth_guard' ) ) -> id ( ) , ] ) ; }
Assigns the customer to the cart record identified by cookie .
50,862
public function storeNewCartData ( $ cartData ) { $ cartItems = $ cartData [ 'items' ] ; unset ( $ cartData [ 'items' ] ) ; $ cartId = $ this -> storeCartDetails ( $ cartData ) ; foreach ( $ cartItems as $ cartItem ) { $ this -> addCartItem ( $ cartId , $ cartItem ) ; } }
Stores the cart and cart items data in the database tables .
50,863
public function addCartItem ( $ cartId , $ cartItem ) { $ cartItem = $ this -> arraySnakeCase ( $ cartItem ) ; $ cartItem [ 'cart_id' ] = $ cartId ; CartItem :: create ( $ cartItem ) ; }
Add a new cart item to the database .
50,864
protected function storeCartDetails ( $ cartData ) { $ cartData = $ this -> arraySnakeCase ( $ cartData ) ; $ cart = Cart :: updateOrCreate ( $ this -> cartIdentifier ( ) , array_merge ( $ cartData , $ this -> getCookieElement ( ) ) ) ; return $ cart -> id ; }
Stores the cart data in the database table and returns the id of the record .
50,865
protected function cartIdentifier ( ) { if ( app ( ) -> offsetExists ( 'cart_auth_user_id' ) ) { return [ 'auth_user' => resolve ( 'cart_auth_user_id' ) ] ; } if ( Auth :: guard ( config ( 'cart_manager.auth_guard' ) ) -> check ( ) ) { return [ 'auth_user' => Auth :: guard ( config ( 'cart_manager.auth_guard' ) ) -> id...
Returns the cart identifier .
50,866
protected function getCookieElement ( ) { if ( ! request ( ) -> hasCookie ( config ( 'cart_manager.cookie_name' ) ) ) { $ cookie = str_random ( 20 ) ; Cookie :: queue ( Cookie :: make ( config ( 'cart_manager.cookie_name' ) , $ cookie , config ( 'cart_manager.cookie_lifetime' ) ) ) ; } else { $ cookie = Cookie :: get (...
Returns the cookie for the cart identification .
50,867
public function clearData ( ) { $ cart = Cart :: where ( $ this -> cartIdentifier ( ) ) -> first ( ) ; if ( $ cart ) { $ cart -> delete ( ) ; } }
Clears the cart details including cart items from the database .
50,868
private function arraySnakeCase ( $ array ) { $ newArray = [ ] ; foreach ( $ array as $ key => $ value ) { $ newArray [ snake_case ( $ key ) ] = $ value ; } return $ newArray ; }
Converts the keys of an array into snake case .
50,869
public function updateItemsData ( $ items ) { $ items -> each ( function ( $ item ) { CartItem :: where ( 'id' , $ item -> id ) -> update ( [ 'name' => $ item -> name , 'price' => $ item -> price , 'image' => $ item -> image , ] ) ; } ) ; }
Updates the details in the cart items table .
50,870
public function download ( $ requests , $ options = array ( ) ) { $ options [ 'CURLOPT_BINARYTRANSFER' ] = 1 ; $ options [ 'RETURNTRANSFER' ] = false ; return $ this -> multi ( $ requests , $ options ) ; }
Download multiple files in parallel
50,871
public function addCurlOptions ( $ curlOptions = array ( ) ) { if ( is_array ( $ curlOptions ) ) { foreach ( $ curlOptions as $ name => $ val ) { $ this -> addCurlOption ( $ name , $ val ) ; } } }
Set curl options
50,872
public function makePostFields ( $ postdata ) { if ( is_object ( $ postdata ) && ! self :: isCurlFile ( $ postdata ) ) { $ postdata = ( array ) $ postdata ; } $ postFields = array ( ) ; foreach ( $ postdata as $ name => $ value ) { $ name = urlencode ( $ name ) ; if ( is_object ( $ value ) && ! self :: isCurlFile ( $ v...
Transform a PHP array into POST parameter
50,873
private function makeArrayField ( $ fieldname , $ arrayData , $ postFields ) { foreach ( $ arrayData as $ key => $ value ) { $ key = urlencode ( $ key ) ; if ( is_object ( $ value ) ) { $ value = ( array ) $ value ; } if ( is_array ( $ value ) ) { $ newfieldname = $ fieldname . "[$key]" ; $ postFields = $ this -> makeA...
Recursive function formating an array in POST parameter
50,874
private function setStylesheet ( $ xslUri ) { $ xslt = $ this -> dom -> createProcessingInstruction ( 'xml-stylesheet' , 'type="text/xsl" href="' . $ xslUri . '"' ) ; $ this -> dom -> appendChild ( $ xslt ) ; }
Set the stylesheet for the WSDL .
50,875
public function addMessage ( $ name , array $ parts ) { $ message = $ this -> dom -> createElement ( 'message' ) ; $ message -> setAttribute ( 'name' , $ name ) ; foreach ( $ parts as $ name => $ type ) { $ part = $ this -> dom -> createElement ( 'part' ) ; $ part -> setAttribute ( 'name' , $ name ) ; if ( is_array ( $...
Add a message element to the WSDL .
50,876
public function addPortType ( $ name ) { $ portType = $ this -> dom -> createElement ( 'portType' ) ; $ portType -> setAttribute ( 'name' , $ name ) ; $ this -> wsdl -> appendChild ( $ portType ) ; return $ portType ; }
Add a portType to element to the WSDL .
50,877
public function addBinding ( $ name , $ portType ) { $ binding = $ this -> dom -> createElement ( 'binding' ) ; $ binding -> setAttribute ( 'name' , $ name ) ; $ binding -> setAttribute ( 'type' , $ portType ) ; $ this -> wsdl -> appendChild ( $ binding ) ; return $ binding ; }
Add a binding element to the WSDL .
50,878
public function addSoapBinding ( DOMElement $ binding , $ style = 'rpc' , $ transport = 'http://schemas.xmlsoap.org/soap/http' ) { $ soapBinding = $ this -> dom -> createElement ( 'soap:binding' ) ; $ soapBinding -> setAttribute ( 'style' , $ style ) ; $ soapBinding -> setAttribute ( 'transport' , $ transport ) ; $ bin...
Add a SOAP binding element to the Binding element .
50,879
public function addBindingOperation ( DOMElement $ binding , $ name , array $ input = null , array $ output = null ) { $ operation = $ this -> dom -> createElement ( 'operation' ) ; $ operation -> setAttribute ( 'name' , $ name ) ; if ( is_array ( $ input ) ) { $ inputElement = $ this -> dom -> createElement ( 'input' ...
Add an operation to a binding element .
50,880
public function addPortOperation ( DOMElement $ portType , $ name , $ inputMessage = null , $ outputMessage = null ) { $ operation = $ this -> dom -> createElement ( 'operation' ) ; $ operation -> setAttribute ( 'name' , $ name ) ; if ( is_string ( $ inputMessage ) && ( strlen ( trim ( $ inputMessage ) ) >= 1 ) ) { $ i...
Add an operation element to a portType element .
50,881
public function addSoapOperation ( DOMElement $ binding , $ soapAction ) { $ soapOperation = $ this -> dom -> createElement ( 'soap:operation' ) ; $ soapOperation -> setAttribute ( 'soapAction' , $ soapAction ) ; $ binding -> insertBefore ( $ soapOperation , $ binding -> firstChild ) ; return $ soapOperation ; }
Add a SOAP operation to an operation element .
50,882
public function addService ( $ name , $ portName , $ binding , $ location ) { $ service = $ this -> dom -> createElement ( 'service' ) ; $ service -> setAttribute ( 'name' , $ name ) ; $ port = $ this -> dom -> createElement ( 'port' ) ; $ port -> setAttribute ( 'name' , $ portName ) ; $ port -> setAttribute ( 'binding...
Add a service element to the WSDL .
50,883
public function addDocumentation ( DOMElement $ inputElement , $ documentation ) { if ( $ inputElement === $ this ) { $ element = $ this -> dom -> documentElement ; } else { $ element = $ inputElement ; } $ doc = $ this -> dom -> createElement ( 'documentation' ) ; $ cdata = $ this -> dom -> createTextNode ( $ document...
Add a documentation element to another element in the WSDL .
50,884
public function getXSDType ( $ type ) { if ( $ this -> isXDSType ( $ type ) ) { return self :: $ XSDTypes [ strtolower ( $ type ) ] ; } elseif ( $ type ) { if ( strpos ( $ type , '[]' ) ) { if ( $ this -> isXDSType ( str_replace ( '[]' , '' , $ type ) ) ) { return self :: $ XSDTypes [ 'array' ] ; } } return $ this -> a...
Get the XSD Type from a PHP type .
50,885
public function addComplexType ( $ type ) { if ( isset ( $ this -> includedTypes [ $ type ] ) ) { return $ this -> includedTypes [ $ type ] ; } if ( strpos ( $ type , '[]' ) !== false ) { return $ this -> addComplexTypeArray ( str_replace ( '[]' , '' , $ type ) , $ type ) ; } $ class = new ReflectionClass ( $ type ) ; ...
Add a complex type .
50,886
protected function addComplexTypeArray ( $ singularType , $ type ) { $ xsdComplexTypeName = 'ArrayOf' . static :: typeToQName ( $ singularType ) ; $ xsdComplexType = 'tns:' . $ xsdComplexTypeName ; $ this -> addType ( $ type , $ xsdComplexType ) ; $ this -> addComplexType ( $ singularType ) ; $ complexType = $ this -> ...
Add an array of complex type .
50,887
public function dump ( $ formatOutput = true ) { if ( $ formatOutput === true ) { $ this -> dom -> formatOutput = true ; } return $ this -> dom -> saveXML ( ) ; }
Dump the WSDL as XML string .
50,888
public function save ( $ filename , $ formatOutput = true ) { if ( $ formatOutput === true ) { $ this -> dom -> formatOutput = true ; } return $ this -> dom -> save ( $ filename ) ; }
Dump the WSDL as file .
50,889
public function setBindingStyle ( $ style , $ transport ) { $ this -> bindingStyle [ 'style' ] = $ style ; $ this -> bindingStyle [ 'transport' ] = $ transport ; return $ this ; }
Set the binding style .
50,890
public function generateWSDL ( $ withAnnotation = false ) { $ qNameClassName = WSDL :: typeToQName ( $ this -> class ) ; $ this -> wsdl = new WSDL ( $ qNameClassName , $ this -> uri , $ this -> xslUri ) ; $ port = $ this -> wsdl -> addPortType ( $ qNameClassName . 'Port' ) ; $ binding = $ this -> wsdl -> addBinding ( $...
Generate the WSDL DOMDocument .
50,891
protected function findModel ( ) { $ class = $ this -> model ; $ query = $ class :: query ( ) ; foreach ( $ this -> input as $ key => $ value ) { $ where = is_array ( $ value ) ? 'whereIn' : 'where' ; $ query -> $ where ( $ key , $ value ) ; } return $ query -> get ( ) ; }
Use the current input to find a record .
50,892
protected function processInput ( ) { if ( empty ( $ this -> input ) ) { $ this -> input = request ( ) -> except ( '_token' ) ; if ( $ this -> injectUserId ) { $ this -> input [ 'user_id' ] = Auth :: user ( ) -> id ; } } $ this -> sanitize ( ) ; request ( ) -> replace ( $ this -> input ) ; }
Retrieve sanitize and update the user input .
50,893
private static function getHashids ( ) { if ( is_null ( static :: $ hashIds ) ) { $ minSlugLength = config ( 'hashslug.minSlugLength' , 5 ) ; if ( isset ( static :: $ minSlugLength ) ) { $ minSlugLength = static :: $ minSlugLength ; } if ( isset ( static :: $ modelSalt ) ) { $ modelSalt = static :: $ modelSalt ; } else...
Returns a chached Hashids instanse or initialises it with salt
50,894
public function slug ( ) { if ( is_null ( $ this -> slug ) ) { $ hashids = $ this -> getHashids ( ) ; $ this -> slug = $ hashids -> encode ( $ this -> { $ this -> getKeyName ( ) } ) ; } return $ this -> slug ; }
Hashslug calculated from id
50,895
public static function decodeSlug ( $ slug ) { $ hashids = static :: getHashids ( ) ; $ decoded = $ hashids -> decode ( $ slug ) ; if ( ! isset ( $ decoded [ 0 ] ) ) { return null ; } return ( int ) $ decoded [ 0 ] ; }
Decodes slug to id
50,896
protected function addLastModel ( ) { if ( ! $ this -> lastModelPopulator ) { return ; } $ this -> addOwners ( $ this -> lastModelPopulator -> getOwners ( ) ) ; $ this -> modelPopulators [ $ this -> lastModelClass ] = $ this -> lastModelPopulator ; $ this -> quantities [ $ this -> lastModelClass ] = $ this -> lastQuant...
Push the ModelPopulator and quantity of the last added model onto their respective fields .
50,897
protected function addOwners ( array $ owners ) { foreach ( $ owners as $ owner ) { if ( isset ( $ this -> modelPopulators [ $ owner ] ) ) { continue ; } $ modelPopulator = new ModelPopulator ( $ this , new $ owner , $ this -> generator , [ ] , [ ] ) ; $ this -> addOwners ( $ modelPopulator -> getOwners ( ) ) ; $ this ...
Recursively add the owners of a model that haven t already been added .
50,898
public function execute ( $ persistLastModel = true ) { $ this -> addLastModel ( ) ; $ insertedPKs = [ ] ; $ createdModels = [ ] ; foreach ( $ this -> quantities as $ modelClass => $ quantity ) { $ this -> modelPopulators [ $ modelClass ] -> setGuessedColumnFormatters ( false ) ; $ persist = $ modelClass === $ this -> ...
Create the added models .
50,899
protected function forgetAddedModels ( ) { $ this -> quantities = $ this -> modelPopulators = [ ] ; $ this -> lastModelPopulator = $ this -> lastModelClass = null ; }
Remove the previously added models .