idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
49,400 | private function resizeCropImage ( UploadedFile $ uploadedFile , $ targetFilepath , $ width , $ height = null , $ squared = false ) { try { $ height = ( ! empty ( $ height ) ? $ height : $ width ) ; $ squared = ( isset ( $ squared ) ? $ squared : false ) ; $ image = $ this -> intervention -> make ( $ uploadedFile ) ; if ( $ squared ) { $ width = ( $ height < $ width ? $ height : $ width ) ; $ height = $ width ; $ image -> fit ( $ width , $ height , function ( $ image ) { $ image -> upsize ( ) ; } ) ; } else { $ image -> resize ( $ width , $ height , function ( $ image ) { $ image -> aspectRatio ( ) ; } ) ; } $ image -> save ( $ targetFilepath , $ this -> quality ) ; $ s3_url = $ this -> saveToS3 ( $ image , $ targetFilepath ) ; return [ 'path' => dirname ( $ targetFilepath ) , 'dir' => $ this -> getRelativePath ( $ targetFilepath ) , 'filename' => pathinfo ( $ targetFilepath , PATHINFO_BASENAME ) , 'filepath' => $ targetFilepath , 'filedir' => $ this -> getRelativePath ( $ targetFilepath ) , 's3_url' => $ s3_url , 'width' => ( int ) $ image -> width ( ) , 'height' => ( int ) $ image -> height ( ) , 'filesize' => ( int ) $ image -> filesize ( ) , 'is_squared' => ( bool ) $ squared , ] ; } catch ( Exception $ e ) { throw new ImageuploadException ( $ e -> getMessage ( ) ) ; } } | Resize file to create thumbnail . |
49,401 | private function createThumbnails ( UploadedFile $ uploadedFile ) { if ( empty ( $ this -> dimensions ) ) { return $ this ; } foreach ( $ this -> dimensions as $ key => $ dimension ) { if ( empty ( $ dimension ) || ! is_array ( $ dimension ) ) { continue ; } list ( $ width , $ height , $ squared ) = $ dimension ; $ targetFilepath = $ this -> getThumbnailsTargetUploadFilepath ( $ key ) ; $ image = $ this -> resizeCropImage ( $ uploadedFile , $ targetFilepath , $ width , $ height , $ squared ) ; if ( ! $ image ) { continue ; } $ this -> results [ 'dimensions' ] [ $ key ] = $ image ; } return $ this ; } | Create thumbnails . |
49,402 | private function returnOutput ( ) { $ collection = new Collection ( $ this -> results ) ; switch ( $ this -> output ) { case 'db' : return $ this -> saveToDatabase ( $ collection ) ; break ; case 'collection' : return $ collection ; break ; case 'json' : return $ collection -> toJson ( ) ; break ; case 'array' : default : return $ collection -> toArray ( ) ; } } | Return output . |
49,403 | private function saveToDatabase ( Collection $ collection ) { $ model = new ImageuploadModel ( ) ; $ fillable = $ model -> getFillable ( ) ; $ input = $ collection -> only ( $ fillable ) -> toArray ( ) ; $ dimensions = $ collection [ 'dimensions' ] ; foreach ( $ dimensions as $ key => $ dimension ) { foreach ( $ dimension as $ k => $ v ) { $ input [ $ key . '_' . $ k ] = $ v ; } } return $ model -> firstOrCreate ( $ input ) ; } | Save output to database and return Model collection . |
49,404 | public function getDimensionKeys ( ) { $ dimensions = Config :: get ( 'imageupload.dimensions' ) ; $ fillable = [ ] ; if ( empty ( $ dimensions ) || ! is_array ( $ dimensions ) ) { return $ fillable ; } foreach ( $ dimensions as $ name => $ dimension ) { foreach ( $ this -> thumbnailKeys as $ key => $ cast ) { array_push ( $ fillable , $ name . '_' . $ key ) ; } } return $ fillable ; } | Get dimension fillable field . |
49,405 | public function setLanguage ( $ language ) { if ( $ this -> getStorageMethod ( ) == 'cookie' ) { return cookie ( ) -> forever ( $ this -> getLanguageKey ( ) , $ language ) ; } if ( interface_exists ( \ Illuminate \ Contracts \ Session \ Session :: class ) && method_exists ( \ Illuminate \ Contracts \ Session \ Session :: class , 'put' ) ) { Session :: put ( $ this -> getLanguageKey ( ) , $ language ) ; } else { Session :: set ( $ this -> getLanguageKey ( ) , $ language ) ; } $ this -> registerLanguage ( ) ; return cookie ( 'dummy-cookie' , FALSE , 1 ) ; } | Sets the language flag and returns the cookie to be created on the redirect |
49,406 | public function getLocalBack ( $ language ) { $ backUrl = redirect ( ) -> back ( ) -> getTargetUrl ( ) ; $ current = $ this -> getCurrentLanguage ( ) ; $ start = strpos ( $ backUrl , $ current ) ; $ count = strlen ( $ current ) ; if ( $ backUrl [ $ start - 1 ] == '/' && ( ! isset ( $ backUrl [ $ start + $ count ] ) ) || $ backUrl [ $ start + $ count ] == '/' ) { $ backUrl = substr_replace ( $ backUrl , $ language , $ start , $ count ) ; } return $ backUrl ; } | Gets the back route with the correct language |
49,407 | public function setLanguage ( $ language ) { if ( Switcher :: getRedirect ( ) == 'route' ) { return redirect ( Switcher :: getRedirectRoute ( ) ) -> withCookie ( Switcher :: setLanguage ( $ language ) ) ; } if ( Switcher :: getRedirect ( ) == 'locale' ) { return redirect ( Switcher :: getLocalBack ( $ language ) ) -> withCookie ( Switcher :: setLanguage ( $ language ) ) ; } return back ( ) -> withCookie ( Switcher :: setLanguage ( $ language ) ) ; } | Set the language and redirect |
49,408 | public function installCustomerAttributes ( ) { foreach ( $ this -> _customerAttributes as $ code => $ attr ) { $ this -> addAttribute ( 'customer' , $ code , $ attr ) ; } return $ this ; } | Add our custom attributes |
49,409 | public function removeCustomerAttributes ( ) { foreach ( $ this -> _customerAttributes as $ code => $ attr ) { $ this -> removeAttribute ( 'customer' , $ code ) ; } return $ this ; } | Remove custom attributes |
49,410 | protected function _loginPostRedirect ( ) { $ session = $ this -> _getCustomerSession ( ) ; if ( ! $ session -> getBeforeAuthUrl ( ) || $ session -> getBeforeAuthUrl ( ) == Mage :: getBaseUrl ( ) ) { $ session -> setBeforeAuthUrl ( $ session -> getSocialConnectRedirect ( ) ) ; if ( $ session -> isLoggedIn ( ) ) { if ( ! Mage :: getStoreConfigFlag ( Mage_Customer_Helper_Data :: XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD ) ) { $ referer = $ this -> getRequest ( ) -> getParam ( Mage_Customer_Helper_Data :: REFERER_QUERY_PARAM_NAME ) ; if ( $ referer ) { $ referer = $ this -> _getModel ( 'core/url' ) -> getRebuiltUrl ( $ this -> _getHelper ( 'core' ) -> urlDecode ( $ referer ) ) ; if ( $ this -> _isUrlInternal ( $ referer ) ) { $ session -> setBeforeAuthUrl ( $ referer ) ; } } } else if ( $ session -> getAfterAuthUrl ( ) ) { $ session -> setBeforeAuthUrl ( $ session -> getAfterAuthUrl ( true ) ) ; } } else { $ session -> setBeforeAuthUrl ( $ this -> _getHelper ( 'customer' ) -> getLoginUrl ( ) ) ; } } else if ( $ session -> getBeforeAuthUrl ( ) == $ this -> _getHelper ( 'customer' ) -> getLogoutUrl ( ) ) { $ session -> setBeforeAuthUrl ( $ this -> _getHelper ( 'customer' ) -> getDashboardUrl ( ) ) ; } else { if ( ! $ session -> getAfterAuthUrl ( ) ) { $ session -> setAfterAuthUrl ( $ session -> getBeforeAuthUrl ( ) ) ; } if ( $ session -> isLoggedIn ( ) ) { $ session -> setBeforeAuthUrl ( $ session -> getAfterAuthUrl ( true ) ) ; } } $ this -> _redirectUrl ( $ session -> getBeforeAuthUrl ( true ) ) ; } | Define target URL and redirect customer after logging in |
49,411 | protected function sanitize ( $ preferences = null ) : Collection { if ( is_null ( $ preferences ) && $ this -> auth -> check ( ) ) { return Collection :: make ( $ this -> auth -> user ( ) -> preferences ) ; } if ( is_null ( $ preferences ) && ! $ this -> auth -> check ( ) ) { return $ this -> allowed ; } if ( is_string ( $ preferences ) ) { $ preferences = json_decode ( $ preferences , true ) ; } return Collection :: make ( $ preferences ) -> filter ( function ( $ item , $ key ) { return $ this -> allowed -> has ( $ key ) ; } ) ; } | Sanitizes the given preferences . |
49,412 | public function update ( string $ key , $ data ) { if ( is_string ( $ data ) ) { $ data = $ this -> normalizeToCollection ( $ data ) ; } if ( $ this -> allowed -> has ( $ key ) ) { $ this -> updatePreferencesForKey ( $ key , $ this -> normalizedTags ( $ data ) ) ; $ this -> updateCategories ( $ data -> pluck ( 'category_id' ) -> unique ( ) ) ; } return $ this ; } | Updates the user preferences for a given key and data . |
49,413 | protected function normalizedTags ( $ data ) : Collection { return $ data -> has ( 'tags' ) ? Collection :: make ( $ data -> get ( 'tags' ) ) : $ data -> pluck ( 'tags' ) ; } | Returns a collection of tags . |
49,414 | protected function updatePreferencesForKey ( string $ key , Collection $ tags ) { $ tags = str_replace ( '"' , '' , $ tags -> implode ( ',' ) ) ; $ tags = Collection :: make ( explode ( ',' , $ tags ) ) -> merge ( explode ( ',' , $ this -> preferences [ $ key ] ) ) -> unique ( ) -> take ( self :: MAX_TAGS ) -> implode ( ',' ) ; $ this -> preferences [ $ key ] = rtrim ( $ tags , ',' ) ; } | Updates the user references for a given key . |
49,415 | protected function updateCategories ( Collection $ data ) { $ ids = explode ( ',' , $ this -> preferences [ 'product_categories' ] ) ; $ categories = Collection :: make ( $ ids ) -> merge ( $ data ) -> unique ( ) -> take ( self :: MAX_TAGS ) -> implode ( ',' ) ; $ this -> preferences [ 'product_categories' ] = trim ( $ categories , ',' ) ; } | Updates the user categories key with the given collection . |
49,416 | public function pluck ( $ key ) : Collection { if ( ! $ this -> preferences -> has ( $ key ) ) { return new Collection ; } return Collection :: make ( explode ( ',' , $ this -> preferences [ $ key ] ) ) ; } | Plucks the given key from the user preferences . |
49,417 | public function all ( $ keys = [ ] ) : Collection { if ( count ( $ keys ) == 0 ) { $ keys = $ this -> preferences -> keys ( ) ; } if ( is_string ( $ keys ) ) { $ keys = [ $ keys ] ; } return Collection :: make ( $ keys ) -> flatMap ( function ( $ item ) { if ( isset ( $ this -> preferences [ $ item ] ) ) { $ result [ $ item ] = explode ( ',' , $ this -> preferences [ $ item ] ) ; } return $ result ?? [ ] ; } ) ; } | Takes the given keys from the preferences array . |
49,418 | protected function resolveQuery ( Builder $ builder , string $ seed ) : Builder { foreach ( $ this -> searchable as $ field ) { $ builder -> orWhere ( $ field , 'like' , '%' . urldecode ( $ seed ) . '%' ) ; } return $ builder ; } | Resolves the query for the given seed . |
49,419 | public function filterable ( $ limit = 5 ) { $ key = md5 ( vsprintf ( '%s' , [ 'filterable_features' ] ) ) ; return Cache :: remember ( $ key , $ this -> remembering , function ( ) use ( $ limit ) { return $ this -> next -> filterable ( $ limit ) ; } ) ; } | Exposes the features allowed to be in the products filtering . |
49,420 | protected function registerPolicies ( ) { foreach ( $ this -> policies as $ model => $ policy ) { Gate :: policy ( $ model , $ policy ) ; } } | Register the antvel policies . |
49,421 | public function setValidationRulesAttribute ( $ value ) { if ( is_string ( $ value ) ) { $ this -> attributes [ 'validation_rules' ] = $ value ; } else { $ this -> attributes [ 'validation_rules' ] = ValidationRulesParser :: parse ( $ value ) -> toString ( ) ; } } | Set the validation_rules with the given value . |
49,422 | public function scopeSuggestionsFor ( $ query , string $ type , array $ tags ) { return ( new SuggestionQuery ( $ query ) ) -> type ( $ type ) -> apply ( $ tags ) ; } | Returns suggestions for a given tags and type . |
49,423 | public function setPicturesAttribute ( array $ attr ) { $ current = $ this -> image ; $ image = Images :: parse ( $ attr ) -> on ( $ this -> storageFolder ( ) ) ; if ( $ image -> wantsDeletion ( ) ) { $ image -> delete ( $ current ) ; return $ this -> attributes [ 'image' ] = null ; } $ picture = $ image -> update ( $ current ) ; return $ this -> attributes [ 'image' ] = $ picture [ 'path' ] ; } | Set the image value of a given model . |
49,424 | public function index ( ) { return view ( 'address.list' , [ 'addresses' => $ addresses = Auth :: user ( ) -> addresses , 'defaultId' => $ addresses -> where ( 'default' , true ) -> pluck ( 'id' ) -> first ( ) , ] ) ; } | Signed user s address book . |
49,425 | public function store ( AddressBookRequest $ request ) { if ( Auth :: user ( ) -> newAddress ( $ request -> all ( ) ) ) { return $ this -> respondsWithSuccess ( trans ( 'address.success_save' ) , route ( 'addressBook.index' ) ) ; } return $ this -> respondsWithError ( trans ( 'address.errors.update' ) ) ; } | Store a new address for the signed user . |
49,426 | public function edit ( int $ id ) { try { $ address = Auth :: user ( ) -> findAddress ( $ id ) ; } catch ( \ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) { return $ this -> respondsWithError ( trans ( 'address.errors.model_not_found' ) ) ; } return view ( 'address.form_edit' , compact ( 'address' ) ) ; } | Show the edition address form . |
49,427 | public function update ( AddressBookRequest $ request , int $ id ) { try { $ address = Auth :: user ( ) -> findAddress ( $ id ) ; } catch ( \ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) { return $ this -> respondsWithError ( trans ( 'address.errors.model_not_found' ) ) ; } $ address -> update ( $ request -> all ( ) ) ; return $ this -> respondsWithSuccess ( trans ( 'address.success_update' ) , route ( 'addressBook.index' ) ) ; } | Update a given address . |
49,428 | public function destroy ( int $ id ) { try { $ address = Auth :: user ( ) -> findAddress ( $ id ) ; } catch ( \ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) { return $ this -> respondsWithError ( trans ( 'address.errors.model_not_found' ) ) ; } $ address -> delete ( ) ; return $ this -> respondsWithSuccess ( '' , route ( 'addressBook.index' ) ) ; } | Remove a given address . |
49,429 | public function setDefault ( Request $ request ) { try { $ address = Auth :: user ( ) -> findAddress ( $ request -> id ) ; } catch ( \ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) { return $ this -> respondsWithError ( trans ( 'address.errors.model_not_found' ) ) ; } Auth :: user ( ) -> resetDefaultAddress ( ) ; $ address -> update ( [ 'default' => true ] ) ; return $ this -> respondsWithSuccess ( '' , route ( 'addressBook.index' ) ) ; } | Setting to default a given address . |
49,430 | protected function categoriesMenu ( ) : array { if ( ! $ this -> app -> bound ( $ repository = 'category.repository.cahe' ) ) { return [ ] ; } return $ this -> app -> make ( $ repository ) -> categoriesWithProducts ( ) -> mapWithKeys ( function ( $ item ) { return [ $ item -> id => $ item ] ; } ) -> all ( ) ; } | Returns the categories menu . |
49,431 | protected function parseInput ( string $ input ) { $ category = explode ( '|' , $ input ) ; if ( isset ( $ category [ 0 ] ) && trim ( $ category [ 0 ] ) != '' ) { $ this -> category_id = urldecode ( $ category [ 0 ] ) ; } if ( isset ( $ category [ 1 ] ) && trim ( $ category [ 1 ] ) != '' ) { $ this -> category_name = urldecode ( $ category [ 1 ] ) ; } } | Parses the given category info . |
49,432 | protected function children ( ) : array { $ categories = App :: make ( 'category.repository.cahe' ) -> childrenOf ( $ this -> category_id , 50 , [ 'id' , 'category_id' , 'name' ] ) ; return Normalizer :: generation ( $ categories ) -> prepend ( ( int ) $ this -> category_id ) -> all ( ) ; } | Returns the children for a given category . |
49,433 | public static function toJson ( $ features ) { if ( is_null ( $ features ) || count ( $ features ) == 0 ) { return null ; } return Collection :: make ( $ features ) -> filter ( function ( $ item ) { return trim ( $ item ) != '' ; } ) -> toJson ( ) ; } | Parses the given features to Json . |
49,434 | public static function replaceTheGivenKeyFor ( $ products , $ oldKey , $ newKey ) : array { return $ products -> mapWithKeys ( function ( $ item ) use ( $ oldKey , $ newKey ) { $ features = $ item -> features ; $ features [ $ newKey ] = $ features [ $ oldKey ] ; unset ( $ features [ $ oldKey ] ) ; return [ $ item -> id => $ features ] ; } ) -> all ( ) ; } | Replaces the given key for another in the provided products features collection . |
49,435 | public function scopeFilter ( $ query , $ request ) { $ request = Arr :: only ( $ request , [ 'name' , 'description' ] ) ; $ query -> actives ( ) -> where ( function ( $ query ) use ( $ request ) { foreach ( $ request as $ key => $ value ) { $ query -> orWhere ( $ key , 'like' , '%' . $ value . '%' ) ; } return $ query ; } ) ; return $ query ; } | Filter categories by the given request . |
49,436 | public function index ( Request $ request ) { $ response [ 'products' ] [ 'results' ] = $ this -> products -> filter ( [ 'search' => $ request -> get ( 'q' ) ] , 4 ) -> get ( ) ; $ response [ 'products' ] [ 'categories' ] = app ( 'category.repository.cahe' ) -> categoriesWithProducts ( [ 'name' => $ request -> get ( 'q' ) , 'description' => $ request -> get ( 'q' ) , ] , 4 , [ 'id' , 'name' ] ) ; $ response [ 'products' ] [ 'suggestions' ] = Suggestions \ Suggest :: for ( 'my_searches' ) -> shake ( ) -> get ( 'my_searches' ) ; $ response [ 'products' ] [ 'categories_title' ] = trans ( 'globals.suggested_categories' ) ; $ response [ 'products' ] [ 'suggestions_title' ] = trans ( 'globals.suggested_products' ) ; $ response [ 'products' ] [ 'results_title' ] = trans ( 'globals.searchResults' ) ; return $ response ; } | Loads the products search . |
49,437 | public static function generation ( Collection $ categories ) : Collection { $ ids = [ ] ; foreach ( $ categories as $ category ) { $ ids [ ] = $ category -> id ; $ ids [ ] = static :: familyTree ( $ category -> childrenRecursive ) ; } return Collection :: make ( $ ids ) -> flatten ( ) -> unique ( ) -> sort ( ) ; } | Returns the generation ids for the given categories . |
49,438 | protected static function familyTree ( Collection $ categories ) : array { $ ids = isset ( $ ids ) && count ( $ ids ) > 0 ? $ ids : [ ] ; foreach ( $ categories as $ category ) { $ ids [ ] = $ category -> id ; if ( $ category -> childrenRecursive -> count ( ) > 0 ) { $ ids [ ] = static :: familyTree ( $ category -> childrenRecursive ) ; } } return $ ids ; } | Returns the family tree ids for the given categories . |
49,439 | public function with ( $ data ) { if ( get_parent_class ( $ data ) === \ Illuminate \ Database \ Eloquent \ Model :: class ) { $ this -> data = [ 'source_id' => $ data -> id , 'status' => $ data -> status ] ; } else { $ this -> data = $ data ; } return $ this ; } | Set the notification data . |
49,440 | public function print ( ) : string { $ label = Templates :: make ( $ this -> source ) -> get ( $ this -> data ( 'status' ) ) ; if ( is_null ( $ label ) ) { return $ this -> defaultLabel ( ) ; } return str_replace ( 'source_id' , $ this -> data ( 'source_id' ) , $ label ) ; } | Prints the notification label . |
49,441 | protected function parse ( array $ sections = [ ] ) { if ( isset ( $ sections [ 'subject' ] ) && ! is_null ( $ sections [ 'subject' ] ) ) { $ this -> subject = $ sections [ 'subject' ] ; } if ( isset ( $ sections [ 'view' ] ) && ! is_null ( $ sections [ 'view' ] ) ) { $ this -> view = $ sections [ 'view' ] ; } } | Parses the email information . |
49,442 | public function updatePreferences ( string $ key , $ data ) { $ current = $ this -> preferences ; $ this -> preferences = PreferencesParser :: parse ( $ current ) -> update ( $ key , $ data ) -> toJson ( ) ; $ this -> save ( ) ; } | Updates the user s preferences for the given key . |
49,443 | public function markNotificationAsRead ( $ notification_id ) { $ notification = $ this -> notifications ( ) -> where ( 'id' , $ notification_id ) -> whereNull ( 'read_at' ) ; if ( $ notification -> exists ( ) ) { $ notification -> first ( ) -> markAsRead ( ) ; } } | Marks the given notification as read . |
49,444 | public function setPreferencesAttribute ( $ preferences ) { if ( is_array ( $ preferences ) ) { $ preferences = json_encode ( $ preferences ) ; } $ this -> attributes [ 'preferences' ] = $ preferences ; } | Set the user s preferences . |
49,445 | public static function confirm ( string $ token , string $ email ) { $ user = static :: where ( 'confirmation_token' , $ token ) -> where ( 'verified' , false ) -> where ( 'email' , $ email ) -> firstOrFail ( ) ; $ user -> verified = true ; $ user -> save ( ) ; return $ user ; } | Confirms the user related to the given token & email . |
49,446 | public function makePetitionFor ( $ new_email ) { $ petition = $ this -> emailChangePetitions ( ) -> unconfirmedByEmail ( $ new_email ) -> first ( ) ; if ( ! is_null ( $ petition ) ) { $ petition -> refresh ( ) ; return $ petition -> fresh ( ) ; } return $ this -> emailChangePetitions ( ) -> create ( [ 'expires_at' => \ Carbon \ Carbon :: now ( ) -> addMonth ( ) , 'old_email' => $ this -> email , 'new_email' => $ new_email , 'token' => str_random ( 60 ) , ] ) ; } | Make a new email change petition with the given data . |
49,447 | public function confirmPetition ( string $ token , string $ email ) { $ petition = $ this -> emailChangePetitions ( ) -> unconfirmedByTokenAndEmail ( $ token , $ email ) -> first ( ) ; if ( ! is_null ( $ petition ) ) { $ petition -> confirmed ( ) ; } $ this -> email = $ email ; $ this -> save ( ) ; } | Mark a found petition by the given token and email as confirmed . |
49,448 | public function default ( ) : Company { $ company = Company :: where ( [ 'status' => true , 'default' => true ] ) -> first ( ) ; if ( is_null ( $ company ) ) { return $ this -> fake ( ) ; } return $ company ; } | Returns the default company . |
49,449 | public function index ( CompanyRepository $ repository , $ section = null ) { if ( is_null ( $ section ) ) { $ section = 'about' ; } $ company = $ repository -> default ( ) ; abort_if ( is_null ( $ company -> $ section ) , 404 ) ; return view ( 'about.index' , [ 'tab' => $ section ] ) ; } | Loads the company about information . |
49,450 | protected static function boot ( ) { parent :: boot ( ) ; static :: creating ( function ( $ comment ) { $ comment -> { $ comment -> getKeyName ( ) } = Uuid :: uuid4 ( ) -> toString ( ) ; } ) ; } | The model boot function . |
49,451 | protected function sourcePath ( $ notifiable ) { if ( $ notifiable -> isAdmin ( ) ) { return route ( 'orders.show_seller_order' , $ this -> order ) ; } return route ( 'orders.show_order' , $ this -> order ) ; } | Returns the notification path . |
49,452 | public static function bindings ( ) { return [ Contracts \ CategoryRepositoryContract :: class => Categories \ Repositories \ CategoriesRepository :: class , Contracts \ FeaturesRepositoryContract :: class => Features \ Repositories \ FeaturesRepository :: class , ] ; } | All of the service bindings for Antvel . |
49,453 | public static function alias ( ) { return [ 'category.repository' => Categories \ Repositories \ CategoriesRepository :: class , 'category.repository.cahe' => Categories \ Repositories \ CategoriesCacheRepository :: class , 'product.features.repository' => Features \ Repositories \ FeaturesRepository :: class , 'product.features.repository.cahe' => Features \ Repositories \ FeaturesCacheRepository :: class , ] ; } | All of the service aliases for Antvel . |
49,454 | protected function modelOrFind ( $ idOrModel ) { if ( $ idOrModel instanceof Model && $ idOrModel -> exists ( ) ) { return $ idOrModel ; } return $ this -> getModel ( ) -> findOrFail ( $ idOrModel ) ; } | Returns the given model instance . |
49,455 | public function paginateWith ( $ loaders , $ constraints = [ ] , $ paginate = [ ] ) { $ categories = $ this -> getModel ( ) -> with ( $ loaders ) ; if ( count ( $ constraints ) > 0 ) { $ categories -> where ( $ constraints ) ; } return $ this -> paginate ( $ categories , $ paginate ) ; } | Paginates the given query and load relationship . |
49,456 | public function find ( $ constraints , $ columns = '*' , ... $ loaders ) { if ( ! is_array ( $ constraints ) ) { $ constraints = [ 'id' => $ constraints ] ; } $ model = $ this -> getModel ( ) -> select ( $ columns ) -> where ( $ constraints ) -> get ( ) ; abort_if ( ! $ model , 404 ) ; if ( count ( $ loaders ) > 0 ) { $ model -> load ( implode ( ',' , $ loaders ) ) ; } return $ model ; } | Find a Model in the Database using the given constraints . |
49,457 | public function apply ( $ constraints ) : Builder { if ( $ constraints && $ this -> type == 'product_categories' ) { return $ this -> builder -> whereIn ( 'category_id' , $ constraints ) ; } if ( $ constraints && is_array ( $ constraints ) ) { return $ this -> filterByConstraints ( $ constraints ) ; } return $ this -> builder ; } | Suggest products based on the given tags . |
49,458 | protected function filterByConstraints ( $ constraints ) : Builder { $ this -> builder -> where ( function ( $ query ) use ( $ constraints ) { foreach ( $ constraints as $ filter ) { if ( trim ( $ filter ) != '' ) { $ query -> orWhere ( 'tags' , 'like' , '%' . $ filter . '%' ) ; } } return $ query ; } ) ; return $ this -> builder ; } | Filter the query by the given constraints . |
49,459 | public static function decode ( $ rules = null ) { $ parser = new static ; if ( is_string ( $ rules ) && trim ( $ rules ) !== '' ) { $ parser -> rules = Collection :: make ( explode ( '|' , $ rules ) ) ; } else { $ parser -> rules = new Collection ; } return $ parser ; } | Creates an instance for the given rules . |
49,460 | protected function mapRules ( $ rules ) : Collection { return Collection :: make ( $ rules ) -> only ( $ this -> allowed ) -> flatMap ( function ( $ item , $ key ) { if ( $ key == 'required' ) { $ rule [ ] = $ item ? 'required' : '' ; } else { $ rule [ ] = $ key . ':' . $ item ; } return $ rule ; } ) ; } | Returns a collection with the given rules . |
49,461 | public function groupWith ( ... $ products ) { $ products = Collection :: make ( $ products ) -> flatten ( ) -> all ( ) ; foreach ( $ products as $ product ) { if ( ! $ this -> hasGroup ( $ product ) ) { $ this -> group ( ) -> attach ( $ product ) ; } } } | Add products to a given group . |
49,462 | public function hasGroup ( $ associated ) : bool { $ associated_id = $ associated instanceof $ this ? $ associated -> id : $ associated ; return ! ! $ this -> group ( ) -> where ( 'associated_id' , $ associated_id ) -> exists ( ) ; } | Checks whether the given product has the associated product in its group . |
49,463 | protected function normalizeNames ( ) { if ( ! $ this -> validFile ( $ this -> imagePath ( ) ) ) { $ this -> image = $ this -> default ( ) ; } if ( $ this -> hasOptions ( ) ) { $ this -> createThumbnail ( ) ; } } | Normalizes the image name . |
49,464 | protected function createThumbnail ( ) { $ this -> thumbnail = $ this -> thumbnailName ( ) ; if ( ! $ this -> validFile ( $ this -> thumbnailPath ( ) ) ) { $ img = $ this -> intervention -> make ( $ this -> imagePath ( ) ) -> resize ( $ this -> width ( ) , $ this -> height ( ) , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; $ constraint -> upsize ( ) ; } ) ; $ img -> save ( $ this -> thumbnailPath ( ) ) ; } } | Creates a new thumbnail . |
49,465 | protected function thumbnailName ( ) { $ file = explode ( '.' , $ this -> image ) ; $ fileName = Arr :: first ( $ file ) ; $ fileExt = Arr :: last ( $ file ) ; return $ fileName . ( $ this -> width ( ) ? '_w' . $ this -> width ( ) : '' ) . ( $ this -> height ( ) ? '_h' . $ this -> height ( ) : '' ) . '.' . $ fileExt ; } | Returns the thumbnail name |
49,466 | public function cast ( ) { $ image = is_null ( $ this -> thumbnail ) ? $ this -> imagePath ( ) : $ this -> thumbnailPath ( ) ; $ imginfo = getimagesize ( $ image ) ; header ( 'Content-type: ' . $ imginfo [ 'mime' ] ) ; readfile ( $ image ) ; } | Renders the given file . |
49,467 | public function mock ( ) { $ image = is_null ( $ this -> thumbnail ) ? $ this -> imagePath ( ) : $ this -> thumbnailPath ( ) ; return $ image ; } | Returns the rendered image path for testing purposes . |
49,468 | protected function resolveQuery ( ) : callable { return function ( $ query ) { foreach ( $ this -> features as $ key => $ feature ) { $ query -> orWhere ( 'features->' . $ key , urldecode ( $ feature ) ) ; } } ; } | Resolve the query for the requested features . |
49,469 | protected function updateProductsFeatures ( array $ attributes , $ products ) { $ products -> each ( function ( $ item , $ key ) use ( $ attributes , $ products ) { $ item -> update ( [ 'features' => json_encode ( $ attributes [ $ item -> id ] ) ] ) ; $ item -> save ( ) ; } ) ; } | Update the given products features with the passed attributes . |
49,470 | public function shoppingCart ( ) { $ shoppingCart = $ this -> orders ( ) -> with ( 'details' ) -> where ( 'type' , 'cart' ) -> first ( ) ; return is_null ( $ shoppingCart ) ? collect ( ) : $ shoppingCart -> details ; } | The user s shopping cart . | while refactoring |
49,471 | public function store ( CategoriesRequest $ request ) { $ category = Category :: create ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'categories.edit' , $ category ) -> with ( 'status' , trans ( 'globals.success_text' ) ) ; } | Stores a new category . |
49,472 | public function update ( CategoriesRequest $ request , Category $ category ) { $ category -> update ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'categories.edit' , $ category ) -> with ( 'status' , trans ( 'globals.success_text' ) ) ; } | Updates the given category . |
49,473 | protected function parseRequest ( array $ request ) : array { $ request = Collection :: make ( $ request ) ; $ allowed = $ request -> filter ( function ( $ item ) { return trim ( $ item ) != '' ; } ) -> only ( array_keys ( $ this -> allowed ) ) ; if ( $ filterable = $ this -> allowedFeatures ( $ request ) ) { $ allowed [ 'features' ] = $ filterable ; } return $ allowed -> all ( ) ; } | Parses the incoming request . |
49,474 | public function allowedFeatures ( Collection $ request ) : array { return $ request -> filter ( function ( $ item , $ key ) { return trim ( $ item ) != '' && $ this -> isFilterable ( $ key ) ; } ) -> all ( ) ; } | Returns an array with the allowed features . |
49,475 | public function apply ( Builder $ builder ) : Builder { if ( $ this -> hasRequest ( ) ) { foreach ( $ this -> request as $ filter => $ value ) { $ this -> resolveQueryFor ( $ builder , $ filter ) ; } } return $ builder ; } | Apply an eloquent query to a given builder . |
49,476 | protected function resolveQueryFor ( Builder $ builder , string $ filter ) : Builder { $ factory = $ this -> allowed [ $ filter ] ; $ input = $ this -> wantsByPrices ( $ filter ) ? $ this -> prices ( ) : $ this -> request [ $ filter ] ; return ( new $ factory ( $ input , $ builder ) ) -> query ( ) ; } | Returns a query filtered by the given filter . |
49,477 | public function index ( Request $ request ) { $ products = $ this -> products -> filter ( $ request -> all ( ) ) ; $ allProducts = $ products -> get ( ) ; if ( Auth :: check ( ) ) { Auth :: user ( ) -> updatePreferences ( 'my_searches' , $ allProducts ) ; } return view ( 'products.index' , [ 'suggestions' => Suggestions \ Suggest :: shakeFor ( $ allProducts ) , 'refine' => Parsers \ Breadcrumb :: parse ( $ request -> all ( ) ) , 'filters' => Parsers \ Filters :: parse ( $ allProducts ) , 'products' => $ products -> paginate ( 28 ) , 'panel' => $ this -> panel , ] ) ; } | Loads the foundation dashboard . |
49,478 | public function indexDashboard ( Request $ request ) { $ products = $ this -> products -> filter ( $ request -> all ( ) ) -> with ( 'creator' , 'updater' ) -> paginate ( 20 ) ; return view ( 'dashboard.sections.products.index' , [ 'products' => $ products , ] ) ; } | List the seller products . |
49,479 | public function show ( Product $ product ) { $ product -> load ( 'group' , 'category' ) ; ( new ProductsRepository ) -> increment ( 'view_counts' , $ product ) ; if ( trim ( $ product -> tags ) != '' && auth ( ) -> check ( ) ) { auth ( ) -> user ( ) -> updatePreferences ( 'product_viewed' , $ product -> tags ) ; } return view ( 'products.detailProd' , [ 'suggestions' => Suggestions \ Suggest :: for ( 'product_viewed' ) -> shake ( ) -> get ( 'product_viewed' ) , 'reviews' => OrderDetail :: ReviewsFor ( $ product -> id ) , 'allWishes' => Order :: forSignedUser ( 'wishlist' ) , 'features' => Feature :: filterable ( ) -> get ( ) , 'product' => $ product , ] ) ; } | Display the given product . |
49,480 | public function create ( Feature $ features ) { return view ( 'dashboard.sections.products.create' , [ 'conditions' => Attributes :: make ( 'condition' ) -> get ( ) , 'features' => $ features -> filterable ( ) -> get ( ) , 'categories' => Category :: actives ( ) -> get ( ) , 'MAX_PICS' => Images :: MAX_PICS , ] ) ; } | Show the creating form . |
49,481 | public function store ( ProductsRequest $ request ) { $ product = $ this -> products -> create ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'items.edit' , [ 'item' => $ product -> id ] ) -> with ( 'status' , trans ( 'globals.success_text' ) ) ; } | Stores a new product . |
49,482 | public function edit ( Models \ Product $ item , Feature $ features ) { return view ( 'dashboard.sections.products.edit' , [ 'MAX_PICS' => Images :: MAX_PICS - $ item -> pictures -> count ( ) , 'conditions' => Attributes :: make ( 'condition' ) -> get ( ) , 'features' => $ features -> filterable ( ) -> get ( ) , 'categories' => Category :: actives ( ) -> get ( ) , 'item' => $ item , ] ) ; } | Show the editing form . |
49,483 | public function update ( ProductsRequest $ request , $ item ) { $ this -> products -> update ( $ request -> all ( ) , $ item ) ; return back ( ) -> with ( 'status' , trans ( 'globals.success_text' ) ) ; } | Updates the given product . |
49,484 | private function extractSnakes ( array $ v_save , $ x , $ y ) { $ snakes = array ( ) ; for ( $ d = count ( $ v_save ) - 1 ; $ x >= 0 && $ y >= 0 ; $ d -- ) { array_unshift ( $ snakes , array ( $ x , $ y ) ) ; $ v = $ v_save [ $ d ] ; $ k = $ x - $ y ; if ( $ k === - $ d || $ k !== $ d && $ v [ $ k - 1 ] < $ v [ $ k + 1 ] ) { $ k_prev = $ k + 1 ; } else { $ k_prev = $ k - 1 ; } $ x = $ v [ $ k_prev ] ; $ y = $ x - $ k_prev ; } return $ snakes ; } | Backtrack through the intermediate results to extract the snakes that are visited on the chosen D - path . |
49,485 | public function respondsWithSuccess ( string $ message , string $ redirectTo = '' ) { return response ( ) -> json ( [ 'redirectTo' => $ redirectTo , 'callback' => $ redirectTo , 'message' => $ message , 'success' => true , ] , 200 ) ; } | Return a success JSON response . |
49,486 | private function groupResults ( ) { $ result = array ( ) ; foreach ( $ this -> nodes as $ node => $ component ) { if ( array_key_exists ( $ component , $ result ) ) { $ result [ $ component ] [ ] = $ node ; } else { $ result [ $ component ] = array ( $ node ) ; } } return $ result ; } | Group the nodes by component . |
49,487 | public function edit ( Request $ request , Product $ itemgroup ) { $ listing = $ this -> products -> filter ( $ request -> all ( ) ) ; return view ( 'dashboard.sections.products.grouping.edit' , [ 'getQueryString' => trim ( $ request -> getQueryString ( ) ) != '' ? $ request -> getQueryString ( ) . '&' : '' , 'filters' => Parsers \ Filters :: parse ( $ listing -> get ( ) ) , 'groupingIds' => $ itemgroup -> group -> pluck ( 'id' ) , 'listing' => $ listing -> paginate ( 25 ) , 'product' => $ itemgroup , ] ) ; } | Edits the given product grouping . |
49,488 | public function update ( Request $ request , Product $ itemgroup ) { $ itemgroup -> groupWith ( $ request -> get ( 'associates' ) ) ; return redirect ( ) -> route ( 'itemgroup.edit' , $ itemgroup ) -> with ( 'status' , trans ( 'globals.success_text' ) ) ; } | Updates the given product grouping . |
49,489 | protected function normalizeProvider ( ConfigRepository $ config ) : string { $ default = $ config -> get ( 'auth.providers.users.model' ) ; if ( is_null ( $ default ) || trim ( $ default ) == '' ) { return \ Antvel \ Users \ Models \ User :: class ; } return $ default ; } | Normalize the authentication provider class name . |
49,490 | public function store ( FeaturesRequest $ request ) { $ feature = Feature :: create ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'features.edit' , $ feature ) -> with ( 'status' , trans ( 'globals.success_text' ) ) ; } | Stores a new feature . |
49,491 | public function update ( FeaturesRequest $ request , Feature $ feature ) { if ( $ request -> has ( 'name' ) && $ feature -> name != $ request -> get ( 'name' ) ) { event ( new FeatureNameWasUpdated ( $ feature , $ request -> get ( 'name' ) ) ) ; } $ feature -> update ( $ request -> except ( 'name' ) ) ; return redirect ( ) -> route ( 'features.edit' , $ feature ) -> with ( 'status' , trans ( 'globals.success_text' ) ) ; } | Updates the given feature . |
49,492 | public function updatePictures ( $ pictures ) { foreach ( $ pictures as $ picture ) { $ image = $ this -> pictures ( ) -> where ( 'id' , $ picture [ 'id' ] ) ; if ( $ image -> exists ( ) ) { $ image -> update ( [ 'path' => $ picture [ 'path' ] ] ) ; } else { $ this -> pictures ( ) -> create ( [ 'path' => $ picture [ 'path' ] ] ) ; } } } | Update the model pictures . |
49,493 | public function deletePictures ( $ ids ) { $ pictures = $ this -> pictures ( ) -> whereIn ( 'id' , $ ids ) -> get ( ) ; $ pictures -> each ( function ( $ item ) { $ item -> delete ( ) ; } ) ; } | Deletes the given pictures from the model . |
49,494 | public function updateDefaultPicture ( $ pictureId ) { if ( $ pictureId ) { $ this -> pictures ( ) -> update ( [ 'default' => false ] ) ; $ this -> pictures ( ) -> where ( 'id' , $ pictureId ) -> update ( [ 'default' => true ] ) ; } } | Updates the given product default picture . |
49,495 | public function getDefaultPictureAttribute ( ) { $ default = $ this -> pictures -> where ( 'default' , true ) -> first ( ) ; if ( $ default ) { return $ default -> path ; } $ picture = $ this -> pictures -> first ( ) ; if ( is_null ( $ picture ) ) { return 'images/no-image.jpg' ; } return $ picture -> path ; } | Returns the product default picture . |
49,496 | public function refresh ( ) { $ this -> expires_at = Carbon :: now ( ) -> addMonth ( ) ; $ this -> token = str_random ( 60 ) ; $ this -> save ( ) ; } | Refresh a given petition . |
49,497 | public function confirmed ( ) { $ this -> confirmed = true ; $ this -> confirmed_at = Carbon :: now ( ) ; $ this -> save ( ) ; } | Confirm a given petition . |
49,498 | public function scopeUnconfirmedByTokenAndEmail ( $ query , string $ token , string $ email ) { return $ query -> where ( 'expires_at' , '>=' , Carbon :: now ( ) ) -> where ( 'new_email' , $ email ) -> where ( 'confirmed' , false ) -> where ( 'token' , $ token ) ; } | Retrieve a petition by the given token and email address . |
49,499 | protected function normalizeBag ( $ bag ) : Collection { return Collection :: make ( $ bag ) -> filter ( function ( $ item ) { return is_string ( $ item ) ? trim ( $ item ) !== '' : $ item ; } ) ; } | Normalize the given bag . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.