idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
1,000
public function sendReceipt ( $ node , $ type = 'read' , $ participant = null , $ callId = null ) { $ messageHash = [ ] ; if ( $ type == 'read' ) { $ messageHash [ 'type' ] = $ type ; } if ( $ participant != null ) { $ messageHash [ 'participant' ] = $ participant ; } $ messageHash [ 'to' ] = $ node -> getAttribute ( '...
Tell the server we received the message .
1,001
public function sendMessageRead ( $ to , $ id ) { $ listNode = null ; $ idNode = $ id ; if ( is_array ( $ id ) && count ( $ id > 1 ) ) { $ idNode = array_shift ( $ id ) ; foreach ( $ id as $ itemId ) { $ items [ ] = new ProtocolNode ( 'item' , [ 'id' => $ itemId , ] , null , null ) ; } $ listNode = new ProtocolNode ( '...
Send a read receipt to a message .
1,002
public function sendNode ( $ node , $ encrypt = true ) { $ this -> timeout = time ( ) ; $ this -> debugPrint ( $ node -> nodeString ( 'tx ' ) . "\n" ) ; $ this -> sendData ( $ this -> writer -> write ( $ node , $ encrypt ) ) ; }
Send node to the WhatsApp server .
1,003
protected function sendRequestFileUpload ( $ b64hash , $ type , $ size , $ filepath , $ to , $ caption = '' ) { $ id = $ this -> createIqId ( ) ; if ( ! is_array ( $ to ) ) { $ to = $ this -> getJID ( $ to ) ; } $ mediaNode = new ProtocolNode ( 'media' , [ 'hash' => $ b64hash , 'type' => $ type , 'size' => $ size , ] ,...
Send request to upload file .
1,004
protected function sendSetPicture ( $ jid , $ filepath ) { $ nodeID = $ this -> createIqId ( ) ; $ data = preprocessProfilePicture ( $ filepath ) ; $ preview = createIconGD ( $ filepath , 96 , true ) ; $ picture = new ProtocolNode ( 'picture' , [ 'type' => 'image' ] , null , $ data ) ; $ preview = new ProtocolNode ( 'p...
Set your profile picture .
1,005
private static function isCli ( ) { if ( self :: $ cli === null ) { if ( php_sapi_name ( ) == 'cli' ) { self :: $ cli = true ; } else { self :: $ cli = false ; } } return self :: $ cli ; }
check if call is from command line .
1,006
public function doLogin ( ) { if ( $ this -> parent -> isLoggedIn ( ) ) { return true ; } $ this -> parent -> writer -> resetKey ( ) ; $ this -> parent -> reader -> resetKey ( ) ; $ resource = Constants :: PLATFORM . '-' . Constants :: WHATSAPP_VER ; $ data = $ this -> parent -> writer -> StartStream ( Constants :: WHA...
Send the nodes to the WhatsApp server to log in .
1,007
protected function createAuthNode ( ) { $ data = $ this -> createAuthBlob ( ) ; $ attributes = [ 'user' => $ this -> phoneNumber , 'mechanism' => 'WAUTH-2' , ] ; $ node = new ProtocolNode ( 'auth' , $ attributes , null , $ data ) ; return $ node ; }
Add the authentication nodes .
1,008
protected function authenticate ( ) { $ keys = KeyStream :: GenerateKeys ( base64_decode ( $ this -> password ) , $ this -> parent -> getChallengeData ( ) ) ; $ this -> inputKey = new KeyStream ( $ keys [ 2 ] , $ keys [ 3 ] ) ; $ this -> outputKey = new KeyStream ( $ keys [ 0 ] , $ keys [ 1 ] ) ; $ array = "\0\0\0\0" ....
Authenticate with the WhatsApp Server .
1,009
public function set ( $ key , $ value ) { if ( property_exists ( $ this , $ key ) && $ key != 'data' ) { $ this -> { $ key } = trim ( $ value ) ; return $ this ; } elseif ( property_exists ( $ this , $ key ) && $ key == 'data' ) { foreach ( $ value as $ v_key => $ v_value ) { $ this -> { $ key } [ $ v_key ] = trim ( $ ...
Global setter .
1,010
private function cleanPostInputs ( ) { $ args = [ 'action' => FILTER_SANITIZE_STRING , 'password' => FILTER_SANITIZE_STRING , 'from' => FILTER_SANITIZE_STRING , 'to' => [ 'filter' => FILTER_SANITIZE_NUMBER_INT , 'flags' => FILTER_REQUIRE_ARRAY , ] , 'message' => FILTER_UNSAFE_RAW , 'image' => FILTER_VALIDATE_URL , 'aud...
Clean and Filter the inputted Form values .
1,011
public function process ( ) { switch ( $ this -> inputs [ 'action' ] ) { case 'login' : $ this -> webLogin ( ) ; break ; case 'logout' : $ this -> webLogout ( ) ; exit ( $ this -> showWebLoginForm ( ) ) ; break ; case 'getContacts' : $ this -> getContacts ( ) ; break ; case 'updateStatus' : $ this -> updateStatus ( ) ;...
Process the latest request .
1,012
private function getContacts ( ) { try { $ this -> waGroupList = [ ] ; $ this -> getGroupList ( ) ; if ( is_array ( $ this -> waGroupList ) ) { $ this -> contacts = array_merge ( $ this -> contacts , $ this -> waGroupList ) ; } $ googleContacts = [ ] ; if ( isset ( $ this -> config [ $ this -> from ] [ 'email' ] ) ) { ...
Get Contacts from various sources to display in form .
1,013
private function connectToWhatsApp ( ) { if ( isset ( $ this -> wa ) ) { $ this -> wa -> connect ( ) ; $ this -> wa -> loginWithPassword ( $ this -> password ) ; return true ; } return false ; }
Connect to Whatsapp .
1,014
public function processReceivedMessage ( $ phone , $ from , $ id , $ type , $ time , $ name , $ data ) { $ matches = null ; $ time = date ( 'Y-m-d H:i:s' , $ time ) ; if ( preg_match ( '/\d*/' , $ from , $ matches ) ) { $ from = $ matches [ 0 ] ; } $ this -> messages [ ] = [ 'phone' => $ phone , 'from' => $ from , 'id'...
Process inbound text messages .
1,015
public function processGroupArray ( $ phone , $ groupArray ) { $ formattedGroups = [ ] ; if ( ! empty ( $ groupArray ) ) { foreach ( $ groupArray as $ group ) { $ formattedGroups [ ] = [ 'name' => 'GROUP: ' . $ group [ 'subject' ] , 'id' => $ group [ 'id' ] ] ; } $ this -> waGroupList = $ formattedGroups ; return true ...
Process the event onGetGroupList and sets a formatted array of groups the user belongs to .
1,016
private function updateStatus ( ) { if ( isset ( $ this -> inputs [ 'status' ] ) && trim ( $ this -> inputs [ 'status' ] ) !== '' ) { $ this -> connectToWhatsApp ( ) ; $ this -> wa -> sendStatusUpdate ( $ this -> inputs [ 'status' ] ) ; exit ( json_encode ( [ 'success' => true , 'data' => "<br />Your status was updated...
Update a users Status .
1,017
private function sendMessage ( ) { if ( is_array ( $ this -> inputs [ 'to' ] ) ) { $ this -> connectToWhatsApp ( ) ; foreach ( $ this -> inputs [ 'to' ] as $ to ) { if ( trim ( $ to ) !== '' ) { if ( isset ( $ this -> inputs [ 'message' ] ) && trim ( $ this -> inputs [ 'message' ] !== '' ) ) { $ this -> wa -> sendMessa...
Sends a message to a contact .
1,018
private function sendBroadcast ( ) { if ( isset ( $ this -> inputs [ 'action' ] ) && trim ( $ this -> inputs [ 'action' ] ) == 'sendBroadcast' ) { $ this -> connectToWhatsApp ( ) ; if ( isset ( $ this -> inputs [ 'message' ] ) && trim ( $ this -> inputs [ 'message' ] !== '' ) ) { $ this -> wa -> sendBroadcastMessage ( ...
Sends a broadcast Message to a group of contacts .
1,019
private function webLogin ( ) { if ( $ this -> inputs [ 'password' ] == $ this -> config [ 'webpassword' ] ) { $ _SESSION [ 'logged_in' ] = true ; exit ( $ this -> showWebForm ( ) ) ; } else { $ error = 'Sorry your password was incorrect.' ; exit ( $ this -> showWebLoginForm ( $ error ) ) ; } }
Process the web login page .
1,020
public function checkCredentials ( ) { if ( ! $ phone = $ this -> dissectPhone ( ) ) { throw new Exception ( 'The provided phone number is not valid.' ) ; } $ countryCode = ( $ phone [ 'ISO3166' ] != '' ) ? $ phone [ 'ISO3166' ] : 'US' ; $ langCode = ( $ phone [ 'ISO639' ] != '' ) ? $ phone [ 'ISO639' ] : 'en' ; $ host...
Check if account credentials are valid .
1,021
public function codeRegister ( $ code ) { if ( ! $ phone = $ this -> dissectPhone ( ) ) { throw new Exception ( 'The provided phone number is not valid.' ) ; } $ code = str_replace ( '-' , '' , $ code ) ; $ countryCode = ( $ phone [ 'ISO3166' ] != '' ) ? $ phone [ 'ISO3166' ] : 'US' ; $ langCode = ( $ phone [ 'ISO639' ...
Register account on WhatsApp using the provided code .
1,022
protected function getResponse ( $ host , $ query ) { $ url = $ host . '?' . http_build_query ( $ query ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , Cons...
Get a decoded JSON response from Whatsapp server .
1,023
protected function dissectPhone ( ) { if ( ( $ handle = fopen ( dirname ( __FILE__ ) . '/countries.csv' , 'rb' ) ) !== false ) { while ( ( $ data = fgetcsv ( $ handle , 1000 ) ) !== false ) { if ( strpos ( $ this -> phoneNumber , $ data [ 1 ] ) === 0 ) { fclose ( $ handle ) ; $ mcc = explode ( '|' , $ data [ 2 ] ) ; $ ...
Dissect country code from phone number .
1,024
protected function detectMnc ( $ lc , $ carrierName ) { $ fp = fopen ( __DIR__ . DIRECTORY_SEPARATOR . 'networkinfo.csv' , 'r' ) ; $ mnc = null ; while ( $ data = fgetcsv ( $ fp , 0 , ',' ) ) { if ( $ data [ 4 ] === $ lc && $ data [ 7 ] === $ carrierName ) { $ mnc = $ data [ 2 ] ; break ; } } if ( $ mnc == null ) { $ m...
Detects mnc from specified carrier .
1,025
protected function buildIdentity ( $ identity_file = false ) { if ( $ identity_file === false ) { $ identity_file = sprintf ( '%s%s%sid.%s.dat' , __DIR__ , DIRECTORY_SEPARATOR , Constants :: DATA_FOLDER . DIRECTORY_SEPARATOR , $ this -> phoneNumber ) ; } if ( is_dir ( $ identity_file ) ) { $ identity_file = sprintf ( '...
Create an identity string .
1,026
public static function writeLog ( $ priority , $ tag , $ msg ) { $ logger = AxolotlLoggerProvider :: getProvider ( ) ; if ( ( $ logger != null ) ) { $ logger -> log ( $ priority , $ tag , $ msg ) ; } }
old function name log
1,027
public function rawColumns ( array $ columns , $ merge = false ) { if ( $ merge ) { $ config = $ this -> config -> get ( 'datatables.columns' ) ; $ this -> columnDef [ 'raw' ] = array_merge ( $ config [ 'raw' ] , $ columns ) ; } else { $ this -> columnDef [ 'raw' ] = $ columns ; } return $ this ; }
Set columns that should not be escaped . Optionally merge the defaults from config .
1,028
public function with ( $ key , $ value = '' ) { if ( is_array ( $ key ) ) { $ this -> appends = $ key ; } elseif ( is_callable ( $ value ) ) { $ this -> appends [ $ key ] = value ( $ value ) ; } else { $ this -> appends [ $ key ] = value ( $ value ) ; } return $ this ; }
Append data on json response .
1,029
protected function getColumnsDefinition ( ) { $ config = $ this -> config -> get ( 'datatables.columns' ) ; $ allowed = [ 'excess' , 'escape' , 'raw' , 'blacklist' , 'whitelist' ] ; return array_replace_recursive ( array_only ( $ config , $ allowed ) , $ this -> columnDef ) ; }
Get columns definition .
1,030
public function filter ( callable $ callback , $ globalSearch = false ) { $ this -> autoFilter = $ globalSearch ; $ this -> isFilterApplied = true ; $ this -> filterCallback = $ callback ; return $ this ; }
Set auto filter off and run your own filter . Overrides global search .
1,031
protected function smartGlobalSearch ( $ keyword ) { collect ( explode ( ' ' , $ keyword ) ) -> reject ( function ( $ keyword ) { return trim ( $ keyword ) === '' ; } ) -> each ( function ( $ keyword ) { $ this -> globalSearch ( $ keyword ) ; } ) ; }
Perform multi - term search by splitting keyword into individual words and searches for each of them .
1,032
protected function transform ( $ results , $ processed ) { if ( isset ( $ this -> transformer ) && class_exists ( 'Yajra\\DataTables\\Transformers\\FractalTransformer' ) ) { return app ( 'datatables.transformer' ) -> transform ( $ results , $ this -> transformer , $ this -> serializer ?? null ) ; } return Helper :: tra...
Transform output .
1,033
protected function processResults ( $ results , $ object = false ) { $ processor = new DataProcessor ( $ results , $ this -> getColumnsDefinition ( ) , $ this -> templates , $ this -> request -> input ( 'start' ) ) ; return $ processor -> process ( $ object ) ; }
Get processed data .
1,034
protected function errorResponse ( \ Exception $ exception ) { $ error = $ this -> config -> get ( 'datatables.error' ) ; $ debug = $ this -> config -> get ( 'app.debug' ) ; if ( $ error === 'throw' || ( ! $ error && ! $ debug ) ) { throw new Exception ( $ exception -> getMessage ( ) , $ code = 0 , $ exception ) ; } $ ...
Return an error json response .
1,035
protected function getColumnNameByIndex ( $ index ) { $ name = ( isset ( $ this -> columns [ $ index ] ) && $ this -> columns [ $ index ] != '*' ) ? $ this -> columns [ $ index ] : $ this -> getPrimaryKeyName ( ) ; return in_array ( $ name , $ this -> extraColumns , true ) ? $ this -> getPrimaryKeyName ( ) : $ name ; }
Get column name by order column index .
1,036
public function addColumns ( array $ names , $ order = false ) { foreach ( $ names as $ name => $ attribute ) { if ( is_int ( $ name ) ) { $ name = $ attribute ; } $ this -> addColumn ( $ name , function ( $ model ) use ( $ attribute ) { return $ model -> getAttribute ( $ attribute ) ; } , is_int ( $ order ) ? $ order ...
Add columns in collection .
1,037
protected function resolveRelationColumn ( $ column ) { $ parts = explode ( '.' , $ column ) ; $ columnName = array_pop ( $ parts ) ; $ relation = implode ( '.' , $ parts ) ; if ( $ this -> isNotEagerLoaded ( $ relation ) ) { return $ column ; } return $ this -> joinEagerLoadedColumn ( $ relation , $ columnName ) ; }
Resolve the proper column name be used .
1,038
protected function isNotEagerLoaded ( $ relation ) { return ! $ relation || ! array_key_exists ( $ relation , $ this -> query -> getEagerLoads ( ) ) || $ relation === $ this -> query -> getModel ( ) -> getTable ( ) ; }
Check if a relation was not used on eager loading .
1,039
public function boot ( ) { $ engines = config ( 'datatables.engines' ) ; foreach ( $ engines as $ engine => $ class ) { $ engine = camel_case ( $ engine ) ; if ( ! method_exists ( DataTables :: class , $ engine ) && ! DataTables :: hasMacro ( $ engine ) ) { DataTables :: macro ( $ engine , function ( ) use ( $ class ) ...
Boot the instance add macros for datatable engines .
1,040
public function rowValue ( $ attribute , $ template ) { if ( ! empty ( $ template ) ) { if ( ! is_callable ( $ template ) && Arr :: get ( $ this -> data , $ template ) ) { $ this -> data [ $ attribute ] = Arr :: get ( $ this -> data , $ template ) ; } else { $ this -> data [ $ attribute ] = Helper :: compileContent ( $...
Process DT RowId and Class value .
1,041
public function rowData ( $ attribute , array $ template ) { if ( count ( $ template ) ) { $ this -> data [ $ attribute ] = [ ] ; foreach ( $ template as $ key => $ value ) { $ this -> data [ $ attribute ] [ $ key ] = Helper :: compileContent ( $ value , $ this -> data , $ this -> row ) ; } } return $ this ; }
Process DT Row Data and Attr .
1,042
public function orderableColumns ( ) { if ( ! $ this -> isOrderable ( ) ) { return [ ] ; } $ orderable = [ ] ; for ( $ i = 0 , $ c = count ( $ this -> request -> input ( 'order' ) ) ; $ i < $ c ; $ i ++ ) { $ order_col = ( int ) $ this -> request -> input ( "order.$i.column" ) ; $ order_dir = strtolower ( $ this -> req...
Get orderable columns .
1,043
public function searchableColumnIndex ( ) { $ searchable = [ ] ; for ( $ i = 0 , $ c = count ( $ this -> request -> input ( 'columns' ) ) ; $ i < $ c ; $ i ++ ) { if ( $ this -> isColumnSearchable ( $ i , false ) ) { $ searchable [ ] = $ i ; } } return $ searchable ; }
Get searchable column indexes .
1,044
public function isColumnSearchable ( $ i , $ column_search = true ) { if ( $ column_search ) { return ( $ this -> request -> input ( "columns.$i.searchable" , 'true' ) === 'true' || $ this -> request -> input ( "columns.$i.searchable" , 'true' ) === true ) && $ this -> columnKeyword ( $ i ) != '' ; } return $ this -> r...
Check if a column is searchable .
1,045
public function columnName ( $ i ) { $ column = $ this -> request -> input ( "columns.$i" ) ; return isset ( $ column [ 'name' ] ) && $ column [ 'name' ] != '' ? $ column [ 'name' ] : $ column [ 'data' ] ; }
Get column identity from input or database .
1,046
public function isPaginationable ( ) { return ! is_null ( $ this -> request -> input ( 'start' ) ) && ! is_null ( $ this -> request -> input ( 'length' ) ) && $ this -> request -> input ( 'length' ) != - 1 ; }
Check if DataTables allow pagination .
1,047
public static function create ( $ source ) { if ( is_array ( $ source ) ) { $ source = new Collection ( $ source ) ; } return parent :: create ( $ source ) ; }
Factory method create and return an instance for the DataTable engine .
1,048
public function count ( ) { return $ this -> collection -> count ( ) > $ this -> totalRecords ? $ this -> totalRecords : $ this -> collection -> count ( ) ; }
Count results .
1,049
private function revertIndexColumn ( $ mDataSupport ) { if ( $ this -> columnDef [ 'index' ] ) { $ index = $ mDataSupport ? config ( 'datatables.index_column' , 'DT_RowIndex' ) : 0 ; $ start = ( int ) $ this -> request -> input ( 'start' ) ; $ this -> collection -> transform ( function ( $ data ) use ( $ index , & $ st...
Revert transformed DT_RowIndex back to it s original values .
1,050
protected function getSorter ( array $ criteria ) { $ sorter = function ( $ a , $ b ) use ( $ criteria ) { foreach ( $ criteria as $ orderable ) { $ column = $ this -> getColumnName ( $ orderable [ 'column' ] ) ; $ direction = $ orderable [ 'direction' ] ; if ( $ direction === 'desc' ) { $ first = $ b ; $ second = $ a ...
Get array sorter closure .
1,051
protected function prepareQuery ( ) { if ( ! $ this -> prepared ) { $ this -> totalRecords = $ this -> totalCount ( ) ; if ( $ this -> totalRecords ) { $ this -> filterRecords ( ) ; $ this -> ordering ( ) ; $ this -> paginate ( ) ; } } $ this -> prepared = true ; }
Prepare query by executing count filter order and paginate .
1,052
public function totalCount ( ) { if ( $ this -> skipTotalRecords ) { return true ; } return $ this -> totalRecords ? $ this -> totalRecords : $ this -> count ( ) ; }
Count total items .
1,053
protected function filteredCount ( ) { $ this -> filteredRecords = $ this -> filteredRecords ? : $ this -> count ( ) ; if ( $ this -> skipTotalRecords ) { $ this -> totalRecords = $ this -> filteredRecords ; } return $ this -> filteredRecords ; }
Count filtered items .
1,054
protected function prepareCountQuery ( ) { $ builder = clone $ this -> query ; if ( ! $ this -> isComplexQuery ( $ builder ) ) { $ row_count = $ this -> wrap ( 'row_count' ) ; $ builder -> select ( $ this -> connection -> raw ( "'1' as {$row_count}" ) ) ; if ( ! $ this -> keepSelectBindings ) { $ builder -> setBindings...
Prepare count query builder .
1,055
protected function getColumnSearchKeyword ( $ i , $ raw = false ) { $ keyword = $ this -> request -> columnKeyword ( $ i ) ; if ( $ raw || $ this -> request -> isRegex ( $ i ) ) { return $ keyword ; } return $ this -> setupKeyword ( $ keyword ) ; }
Get column keyword to use for search .
1,056
protected function applyFilterColumn ( $ query , $ columnName , $ keyword , $ boolean = 'and' ) { $ query = $ this -> getBaseQueryBuilder ( $ query ) ; $ callback = $ this -> columnDef [ 'filter' ] [ $ columnName ] [ 'method' ] ; if ( $ this -> query instanceof EloquentBuilder ) { $ builder = $ this -> query -> newMode...
Apply filterColumn api search .
1,057
protected function getBaseQueryBuilder ( $ instance = null ) { if ( ! $ instance ) { $ instance = $ this -> query ; } if ( $ instance instanceof EloquentBuilder ) { return $ instance -> getQuery ( ) ; } return $ instance ; }
Get the base query builder instance .
1,058
protected function addTablePrefix ( $ query , $ column ) { if ( strpos ( $ column , '.' ) === false ) { $ q = $ this -> getBaseQueryBuilder ( $ query ) ; if ( ! $ q -> from instanceof Expression ) { $ column = $ q -> from . '.' . $ column ; } } return $ this -> wrap ( $ column ) ; }
Patch for fix about ambiguous field . Ambiguous field error will appear when query use join table and search with keyword .
1,059
protected function prepareKeyword ( $ keyword ) { if ( $ this -> config -> isCaseInsensitive ( ) ) { $ keyword = Str :: lower ( $ keyword ) ; } if ( $ this -> config -> isWildcard ( ) ) { $ keyword = Helper :: wildcardLikeString ( $ keyword ) ; } if ( $ this -> config -> isSmartSearch ( ) ) { $ keyword = "%$keyword%" ;...
Prepare search keyword based on configurations .
1,060
public function orderColumns ( array $ columns , $ sql , $ bindings = [ ] ) { foreach ( $ columns as $ column ) { $ this -> orderColumn ( $ column , str_replace ( ':column' , $ column , $ sql ) , $ bindings ) ; } return $ this ; }
Order each given columns versus the given custom sql .
1,061
protected function applyOrderColumn ( $ column , $ orderable ) { $ sql = $ this -> columnDef [ 'order' ] [ $ column ] [ 'sql' ] ; $ sql = str_replace ( '$1' , $ orderable [ 'direction' ] , $ sql ) ; $ bindings = $ this -> columnDef [ 'order' ] [ $ column ] [ 'bindings' ] ; $ this -> query -> orderByRaw ( $ sql , $ bind...
Apply orderColumn custom query .
1,062
protected function getNullsLastSql ( $ column , $ direction ) { $ sql = $ this -> config -> get ( 'datatables.nulls_last_sql' , '%s %s NULLS LAST' ) ; return sprintf ( $ sql , $ column , $ direction ) ; }
Get NULLS LAST SQL .
1,063
protected function showDebugger ( array $ output ) { $ output [ 'queries' ] = $ this -> connection -> getQueryLog ( ) ; $ output [ 'input' ] = $ this -> request -> all ( ) ; return $ output ; }
Append debug parameters on output .
1,064
protected function attachAppends ( array $ data ) { $ appends = [ ] ; foreach ( $ this -> appends as $ key => $ value ) { if ( is_callable ( $ value ) ) { $ appends [ $ key ] = value ( $ value ( $ this -> getFilteredQuery ( ) ) ) ; } else { $ appends [ $ key ] = $ value ; } } return array_merge ( $ data , $ appends ) ;...
Attach custom with meta on response .
1,065
public static function make ( $ source ) { $ engines = config ( 'datatables.engines' ) ; $ builders = config ( 'datatables.builders' ) ; $ args = func_get_args ( ) ; foreach ( $ builders as $ class => $ engine ) { if ( $ source instanceof $ class ) { return call_user_func_array ( [ $ engines [ $ engine ] , 'create' ] ,...
Make a DataTable instance from source .
1,066
public function process ( $ object = false ) { $ this -> output = [ ] ; $ indexColumn = config ( 'datatables.index_column' , 'DT_RowIndex' ) ; foreach ( $ this -> results as $ row ) { $ data = Helper :: convertToArray ( $ row ) ; $ value = $ this -> addColumns ( $ data , $ row ) ; $ value = $ this -> editColumns ( $ va...
Process data to output on browser .
1,067
protected function addColumns ( $ data , $ row ) { foreach ( $ this -> appendColumns as $ key => $ value ) { $ value [ 'content' ] = Helper :: compileContent ( $ value [ 'content' ] , $ data , $ row ) ; $ data = Helper :: includeInArray ( $ value , $ data ) ; } return $ data ; }
Process add columns .
1,068
protected function editColumns ( $ data , $ row ) { foreach ( $ this -> editColumns as $ key => $ value ) { $ value [ 'content' ] = Helper :: compileContent ( $ value [ 'content' ] , $ data , $ row ) ; Arr :: set ( $ data , $ value [ 'name' ] , $ value [ 'content' ] ) ; } return $ data ; }
Process edit columns .
1,069
protected function setupRowVariables ( $ data , $ row ) { $ processor = new RowProcessor ( $ data , $ row ) ; return $ processor -> rowValue ( 'DT_RowId' , $ this -> templates [ 'DT_RowId' ] ) -> rowValue ( 'DT_RowClass' , $ this -> templates [ 'DT_RowClass' ] ) -> rowData ( 'DT_RowData' , $ this -> templates [ 'DT_Row...
Setup additional DT row variables .
1,070
protected function selectOnlyNeededColumns ( array $ data ) { if ( is_null ( $ this -> onlyColumns ) ) { return $ data ; } else { return array_intersect_key ( $ data , array_flip ( array_merge ( $ this -> onlyColumns , $ this -> exceptions ) ) ) ; } }
Get only needed columns .
1,071
public function flatten ( array $ array ) { $ return = [ ] ; foreach ( $ array as $ key => $ value ) { if ( in_array ( $ key , $ this -> exceptions ) ) { $ return [ $ key ] = $ value ; } else { $ return [ ] = $ value ; } } return $ return ; }
Flatten array with exceptions .
1,072
protected function escapeColumns ( array $ output ) { return array_map ( function ( $ row ) { if ( $ this -> escapeColumns == '*' ) { $ row = $ this -> escapeRow ( $ row ) ; } elseif ( is_array ( $ this -> escapeColumns ) ) { $ columns = array_diff ( $ this -> escapeColumns , $ this -> rawColumns ) ; foreach ( $ column...
Escape column values as declared .
1,073
protected function escapeRow ( array $ row ) { $ arrayDot = array_filter ( array_dot ( $ row ) ) ; foreach ( $ arrayDot as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> rawColumns ) ) { $ arrayDot [ $ key ] = e ( $ value ) ; } } foreach ( $ arrayDot as $ key => $ value ) { array_set ( $ row , $ key , $ value...
Escape all values of row .
1,074
public static function includeInArray ( $ item , $ array ) { if ( self :: isItemOrderInvalid ( $ item , $ array ) ) { return array_merge ( $ array , [ $ item [ 'name' ] => $ item [ 'content' ] ] ) ; } $ count = 0 ; $ last = $ array ; $ first = [ ] ; foreach ( $ array as $ key => $ value ) { if ( $ count == $ item [ 'or...
Places item of extra columns into results by care of their order .
1,075
public static function compileContent ( $ content , array $ data , $ param ) { if ( is_string ( $ content ) ) { return static :: compileBlade ( $ content , static :: getMixedValue ( $ data , $ param ) ) ; } elseif ( is_callable ( $ content ) ) { return $ content ( $ param ) ; } return $ content ; }
Determines if content is callable or blade string processes and returns .
1,076
public static function compileBlade ( $ str , $ data = [ ] ) { if ( view ( ) -> exists ( $ str ) ) { return view ( $ str , $ data ) -> render ( ) ; } ob_start ( ) && extract ( $ data , EXTR_SKIP ) ; eval ( '?>' . app ( 'blade.compiler' ) -> compileString ( $ str ) ) ; $ str = ob_get_contents ( ) ; ob_end_clean ( ) ; re...
Parses and compiles strings by using Blade Template System .
1,077
public static function getMixedValue ( array $ data , $ param ) { $ casted = self :: castToArray ( $ param ) ; $ data [ 'model' ] = $ param ; foreach ( $ data as $ key => $ value ) { if ( isset ( $ casted [ $ key ] ) ) { $ data [ $ key ] = $ casted [ $ key ] ; } } return $ data ; }
Get a mixed value of custom data and the parameters .
1,078
public static function castToArray ( $ param ) { if ( $ param instanceof \ stdClass ) { $ param = ( array ) $ param ; return $ param ; } if ( $ param instanceof Arrayable ) { return $ param -> toArray ( ) ; } return $ param ; }
Cast the parameter into an array .
1,079
public static function getOrMethod ( $ method ) { if ( ! Str :: contains ( Str :: lower ( $ method ) , 'or' ) ) { return 'or' . ucfirst ( $ method ) ; } return $ method ; }
Get equivalent or method of query builder .
1,080
public static function convertToArray ( $ row ) { $ data = $ row instanceof Arrayable ? $ row -> toArray ( ) : ( array ) $ row ; foreach ( $ data as & $ value ) { if ( is_object ( $ value ) || is_array ( $ value ) ) { $ value = self :: convertToArray ( $ value ) ; } unset ( $ value ) ; } return $ data ; }
Converts array object values to associative array .
1,081
protected static function transformRow ( $ row ) { foreach ( $ row as $ key => $ value ) { if ( $ value instanceof DateTime ) { $ row [ $ key ] = $ value -> format ( 'Y-m-d H:i:s' ) ; } else { if ( is_object ( $ value ) ) { $ row [ $ key ] = ( string ) $ value ; } else { $ row [ $ key ] = $ value ; } } } return $ row ;...
Transform row data into an array .
1,082
public static function replacePatternWithKeyword ( array $ subject , $ keyword , $ pattern = '$1' ) { $ parameters = [ ] ; foreach ( $ subject as $ param ) { if ( is_array ( $ param ) ) { $ parameters [ ] = self :: replacePatternWithKeyword ( $ param , $ keyword , $ pattern ) ; } else { $ parameters [ ] = str_replace (...
Replace all pattern occurrences with keyword .
1,083
public static function extractColumnName ( $ str , $ wantsAlias ) { $ matches = explode ( ' as ' , Str :: lower ( $ str ) ) ; if ( ! empty ( $ matches ) ) { if ( $ wantsAlias ) { return array_pop ( $ matches ) ; } return array_shift ( $ matches ) ; } elseif ( strpos ( $ str , '.' ) ) { $ array = explode ( '.' , $ str )...
Get column name from string .
1,084
public static function wildcardString ( $ str , $ wildcard , $ lowercase = true ) { $ wild = $ wildcard ; $ chars = preg_split ( '//u' , $ str , - 1 , PREG_SPLIT_NO_EMPTY ) ; if ( count ( $ chars ) > 0 ) { foreach ( $ chars as $ char ) { $ wild .= $ char . $ wildcard ; } } if ( $ lowercase ) { $ wild = Str :: lower ( $...
Adds wildcards to the given string .
1,085
public function getCollection ( HasMedia $ model , string $ collectionName , $ filter = [ ] ) : Collection { return $ this -> applyFilterToMediaCollection ( $ model -> loadMedia ( $ collectionName ) , $ filter ) ; }
Get all media in the collection .
1,086
protected function applyFilterToMediaCollection ( Collection $ media , $ filter ) : Collection { if ( is_array ( $ filter ) ) { $ filter = $ this -> getDefaultFilterFunction ( $ filter ) ; } return $ media -> filter ( $ filter ) ; }
Apply given filters on media .
1,087
protected function getDefaultFilterFunction ( array $ filters ) : Closure { return function ( Media $ media ) use ( $ filters ) { foreach ( $ filters as $ property => $ value ) { if ( ! Arr :: has ( $ media -> custom_properties , $ property ) ) { return false ; } if ( Arr :: get ( $ media -> custom_properties , $ prope...
Convert the given array to a filter function .
1,088
public function setManipulations ( $ manipulations ) : self { if ( $ manipulations instanceof Manipulations ) { $ this -> manipulations = $ this -> manipulations -> mergeManipulations ( $ manipulations ) ; } if ( is_callable ( $ manipulations ) ) { $ manipulations ( $ this -> manipulations ) ; } return $ this ; }
Set the manipulations for this conversion .
1,089
public function addAsFirstManipulations ( Manipulations $ manipulations ) : self { $ manipulationSequence = $ manipulations -> getManipulationSequence ( ) -> toArray ( ) ; $ this -> manipulations -> getManipulationSequence ( ) -> mergeArray ( $ manipulationSequence ) ; return $ this ; }
Add the given manipulations as the first ones .
1,090
public function createDerivedFiles ( Media $ media , array $ only = [ ] , $ onlyIfMissing = false ) { $ profileCollection = ConversionCollection :: createForMedia ( $ media ) ; if ( ! empty ( $ only ) ) { $ profileCollection = $ profileCollection -> filter ( function ( $ collection ) use ( $ only ) { return in_array ( ...
Create all derived files for the given media .
1,091
public function performConversions ( ConversionCollection $ conversions , Media $ media , $ onlyIfMissing = false ) { if ( $ conversions -> isEmpty ( ) ) { return ; } $ imageGenerator = $ this -> determineImageGenerator ( $ media ) ; if ( ! $ imageGenerator ) { return ; } $ temporaryDirectory = TemporaryDirectory :: cr...
Perform the given conversions for the given media .
1,092
public function getResponsiveImagesDirectoryUrl ( ) : string { return url ( $ this -> getBaseMediaDirectoryUrl ( ) . '/' . $ this -> pathGenerator -> getPathForResponsiveImages ( $ this -> media ) ) . '/' ; }
Get the url to the directory containing responsive images .
1,093
public function getByName ( string $ name ) : Conversion { $ conversion = $ this -> first ( function ( Conversion $ conversion ) use ( $ name ) { return $ conversion -> getName ( ) === $ name ; } ) ; if ( ! $ conversion ) { throw InvalidConversion :: unknownName ( $ name ) ; } return $ conversion ; }
Get a conversion by it s name .
1,094
protected function addConversionsFromRelatedModel ( Media $ media ) { $ modelName = Arr :: get ( Relation :: morphMap ( ) , $ media -> model_type , $ media -> model_type ) ; $ model = new $ modelName ( ) ; if ( $ model -> registerMediaConversionsUsingModelInstance ) { $ model = $ media -> model ; $ model -> mediaConver...
Add the conversion that are defined on the related model of the given media .
1,095
protected function addManipulationsFromDb ( Media $ media ) { collect ( $ media -> manipulations ) -> each ( function ( $ manipulations , $ conversionName ) { $ this -> addManipulationToConversion ( new Manipulations ( [ $ manipulations ] ) , $ conversionName ) ; } ) ; }
Add the extra manipulations that are defined on the given media .
1,096
public function getTemporaryUrl ( DateTimeInterface $ expiration , array $ options = [ ] ) : string { return $ this -> filesystemManager -> disk ( $ this -> media -> disk ) -> temporaryUrl ( $ this -> getPath ( ) , $ expiration , $ options ) ; }
Get the temporary url for a media item .
1,097
public function addMediaFromUrl ( string $ url , ... $ allowedMimeTypes ) { if ( ! $ stream = @ fopen ( $ url , 'r' ) ) { throw UnreachableUrl :: create ( $ url ) ; } $ temporaryFile = tempnam ( sys_get_temp_dir ( ) , 'media-library' ) ; file_put_contents ( $ temporaryFile , $ stream ) ; $ this -> guardAgainstInvalidMi...
Add a remote file to the medialibrary .
1,098
public function addMediaFromBase64 ( string $ base64data , ... $ allowedMimeTypes ) : FileAdder { if ( strpos ( $ base64data , ';base64' ) !== false ) { [ $ _ , $ base64data ] = explode ( ';' , $ base64data ) ; [ $ _ , $ base64data ] = explode ( ',' , $ base64data ) ; } if ( base64_decode ( $ base64data , true ) === fa...
Add a base64 encoded file to the medialibrary .
1,099
public function updateMedia ( array $ newMediaArray , string $ collectionName = 'default' ) : Collection { $ this -> removeMediaItemsNotPresentInArray ( $ newMediaArray , $ collectionName ) ; return collect ( $ newMediaArray ) -> map ( function ( array $ newMediaItem ) use ( $ collectionName ) { static $ orderColumn = ...
Update a media collection by deleting and inserting again with new values .