Overview

Namespaces

  • Composer
    • Autoload
  • Illuminate
    • Support
      • Contracts
      • Facades
  • Laravella
    • Cart
      • Facades
  • None
  • PHP

Classes

  • CartController
  • ComposerAutoloaderInit9c0b006a4274a87b7a6105d88b65eda5
  • CreateContactsTable
  • CreateContactTypesTable
  • CreateProductCategoriesTable
  • CreateProductsTable
  • DatabaseSeeder
  • DbController
  • Generic
  • ProductsSeeder

Functions

  • action
  • app
  • app_path
  • array_add
  • array_build
  • array_divide
  • array_dot
  • array_except
  • array_fetch
  • array_first
  • array_flatten
  • array_forget
  • array_get
  • array_only
  • array_pluck
  • array_pull
  • array_set
  • array_sort
  • asset
  • base_path
  • camel_case
  • class_basename
  • csrf_token
  • dd
  • e
  • ends_with
  • head
  • last
  • link_to
  • link_to_action
  • link_to_asset
  • link_to_route
  • object_get
  • public_path
  • route
  • secure_asset
  • secure_url
  • snake_case
  • starts_with
  • storage_path
  • str_contains
  • str_finish
  • str_is
  • str_plural
  • str_random
  • str_singular
  • studly_case
  • trans
  • trans_choice
  • url
  • value
  • with
  • Overview
  • Namespace
  • Function
  • Tree
  1: <?php
  2: 
  3: if ( ! function_exists('action'))
  4: {
  5:     /**
  6:      * Generate a URL to a controller action.
  7:      *
  8:      * @param  string  $name
  9:      * @param  string  $parameters
 10:      * @param  bool    $absolute
 11:      * @return string
 12:      */
 13:     function action($name, $parameters = array(), $absolute = true)
 14:     {
 15:         return app('url')->action($name, $parameters, $absolute);
 16:     }
 17: }
 18: 
 19: if ( ! function_exists('app'))
 20: {
 21:     /**
 22:      * Get the root Facade application instance.
 23:      *
 24:      * @param  string  $make
 25:      * @return mixed
 26:      */
 27:     function app($make = null)
 28:     {
 29:         if ( ! is_null($make))
 30:         {
 31:             return app()->make($make);
 32:         }
 33: 
 34:         return Illuminate\Support\Facades\Facade::getFacadeApplication();
 35:     }
 36: }
 37: 
 38: if ( ! function_exists('app_path'))
 39: {
 40:     /**
 41:      * Get the path to the application folder.
 42:      *
 43:      * @return  string
 44:      */
 45:     function app_path()
 46:     {
 47:         return app('path');
 48:     }
 49: }
 50: 
 51: if ( ! function_exists('array_add'))
 52: {
 53:     /**
 54:      * Add an element to an array if it doesn't exist.
 55:      *
 56:      * @param  array   $array
 57:      * @param  string  $key
 58:      * @param  mixed   $value
 59:      * @return array
 60:      */
 61:     function array_add($array, $key, $value)
 62:     {
 63:         if ( ! isset($array[$key])) $array[$key] = $value;
 64: 
 65:         return $array;
 66:     }
 67: }
 68: 
 69: if ( ! function_exists('array_build'))
 70: {
 71:     /**
 72:      * Build a new array using a callback.
 73:      *
 74:      * @param  array  $array
 75:      * @param  \Closure  $callback
 76:      * @return array
 77:      */
 78:     function array_build($array, Closure $callback)
 79:     {
 80:         $results = array();
 81: 
 82:         foreach ($array as $key => $value)
 83:         {
 84:             list($innerKey, $innerValue) = call_user_func($callback, $key, $value);
 85: 
 86:             $results[$innerKey] = $innerValue;
 87:         }
 88: 
 89:         return $results;
 90:     }
 91: }
 92: 
 93: if ( ! function_exists('array_divide'))
 94: {
 95:     /**
 96:      * Divide an array into two arrays. One with keys and the other with values.
 97:      *
 98:      * @param  array  $array
 99:      * @return array
100:      */
101:     function array_divide($array)
102:     {
103:         return array(array_keys($array), array_values($array));
104:     }
105: }
106: 
107: if ( ! function_exists('array_dot'))
108: {
109:     /**
110:      * Flatten a multi-dimensional associative array with dots.
111:      *
112:      * @param  array   $array
113:      * @param  string  $prepend
114:      * @return array
115:      */
116:     function array_dot($array, $prepend = '')
117:     {
118:         $results = array();
119: 
120:         foreach ($array as $key => $value)
121:         {
122:             if (is_array($value))
123:             {
124:                 $results = array_merge($results, array_dot($value, $prepend.$key.'.'));
125:             }
126:             else
127:             {
128:                 $results[$prepend.$key] = $value;
129:             }
130:         }
131: 
132:         return $results;
133:     }
134: }
135: 
136: if ( ! function_exists('array_except'))
137: {
138:     /**
139:      * Get all of the given array except for a specified array of items.
140:      *
141:      * @param  array  $array
142:      * @param  array  $keys
143:      * @return array
144:      */
145:     function array_except($array, $keys)
146:     {
147:         return array_diff_key($array, array_flip((array) $keys));
148:     }
149: }
150: 
151: if ( ! function_exists('array_fetch'))
152: {
153:     /**
154:      * Fetch a flattened array of a nested array element.
155:      *
156:      * @param  array   $array
157:      * @param  string  $key
158:      * @return array
159:      */
160:     function array_fetch($array, $key)
161:     {
162:         foreach (explode('.', $key) as $segment)
163:         {
164:             $results = array();
165: 
166:             foreach ($array as $value)
167:             {
168:                 $value = (array) $value;
169: 
170:                 $results[] = $value[$segment];
171:             }
172: 
173:             $array = array_values($results);
174:         }
175: 
176:         return array_values($results);
177:     }
178: }
179: 
180: if ( ! function_exists('array_first'))
181: {
182:     /**
183:      * Return the first element in an array passing a given truth test.
184:      *
185:      * @param  array    $array
186:      * @param  Closure  $callback
187:      * @param  mixed    $default
188:      * @return mixed
189:      */
190:     function array_first($array, $callback, $default = null)
191:     {
192:         foreach ($array as $key => $value)
193:         {
194:             if (call_user_func($callback, $key, $value)) return $value;
195:         }
196: 
197:         return value($default);
198:     }
199: }
200: 
201: if ( ! function_exists('array_flatten'))
202: {
203:     /**
204:      * Flatten a multi-dimensional array into a single level.
205:      *
206:      * @param  array  $array
207:      * @return array
208:      */
209:     function array_flatten($array)
210:     {
211:         $return = array();
212: 
213:         array_walk_recursive($array, function($x) use (&$return) { $return[] = $x; });
214: 
215:         return $return;
216:     }
217: }
218: 
219: if ( ! function_exists('array_forget'))
220: {
221:     /**
222:      * Remove an array item from a given array using "dot" notation.
223:      *
224:      * @param  array   $array
225:      * @param  string  $key
226:      * @return void
227:      */
228:     function array_forget(&$array, $key)
229:     {
230:         $keys = explode('.', $key);
231: 
232:         while (count($keys) > 1)
233:         {
234:             $key = array_shift($keys);
235: 
236:             if ( ! isset($array[$key]) or ! is_array($array[$key]))
237:             {
238:                 return;
239:             }
240: 
241:             $array =& $array[$key];
242:         }
243: 
244:         unset($array[array_shift($keys)]);
245:     }
246: }
247: 
248: if ( ! function_exists('array_get'))
249: {
250:     /**
251:      * Get an item from an array using "dot" notation.
252:      *
253:      * @param  array   $array
254:      * @param  string  $key
255:      * @param  mixed   $default
256:      * @return mixed
257:      */
258:     function array_get($array, $key, $default = null)
259:     {
260:         if (is_null($key)) return $array;
261:         
262:         if (isset($array[$key])) return $array[$key];
263: 
264:         foreach (explode('.', $key) as $segment)
265:         {
266:             if ( ! is_array($array) or ! array_key_exists($segment, $array))
267:             {
268:                 return value($default);
269:             }
270: 
271:             $array = $array[$segment];
272:         }
273: 
274:         return $array;
275:     }
276: }
277: 
278: if ( ! function_exists('array_only'))
279: {
280:     /**
281:      * Get a subset of the items from the given array.
282:      *
283:      * @param  array  $array
284:      * @param  array  $keys
285:      * @return array
286:      */
287:     function array_only($array, $keys)
288:     {
289:         return array_intersect_key($array, array_flip((array) $keys));
290:     }
291: }
292: 
293: if ( ! function_exists('array_pluck'))
294: {
295:     /**
296:      * Pluck an array of values from an array.
297:      *
298:      * @param  array   $array
299:      * @param  string  $key
300:      * @return array
301:      */
302:     function array_pluck($array, $key)
303:     {
304:         return array_map(function($value) use ($key)
305:         {
306:             return is_object($value) ? $value->$key : $value[$key];
307: 
308:         }, $array);
309:     }
310: }
311: 
312: if ( ! function_exists('array_pull'))
313: {
314:     /**
315:      * Get a value from the array, and remove it.
316:      *
317:      * @param  array   $array
318:      * @param  string  $key
319:      * @return mixed
320:      */
321:     function array_pull(&$array, $key)
322:     {
323:         $value = array_get($array, $key);
324: 
325:         array_forget($array, $key);
326: 
327:         return $value;
328:     }
329: }
330: 
331: if ( ! function_exists('array_set'))
332: {
333:     /**
334:      * Set an array item to a given value using "dot" notation.
335:      *
336:      * If no key is given to the method, the entire array will be replaced.
337:      *
338:      * @param  array   $array
339:      * @param  string  $key
340:      * @param  mixed   $value
341:      * @return void
342:      */
343:     function array_set(&$array, $key, $value)
344:     {
345:         if (is_null($key)) return $array = $value;
346: 
347:         $keys = explode('.', $key);
348: 
349:         while (count($keys) > 1)
350:         {
351:             $key = array_shift($keys);
352: 
353:             // If the key doesn't exist at this depth, we will just create an empty array
354:             // to hold the next value, allowing us to create the arrays to hold final
355:             // values at the correct depth. Then we'll keep digging into the array.
356:             if ( ! isset($array[$key]) or ! is_array($array[$key]))
357:             {
358:                 $array[$key] = array();
359:             }
360: 
361:             $array =& $array[$key];
362:         }
363: 
364:         $array[array_shift($keys)] = $value;
365:     }
366: }
367: 
368: if ( ! function_exists('array_sort'))
369: {
370:     /**
371:      * Sort the array using the given Closure.
372:      *
373:      * @param  array  $array
374:      * @param  \Closure  $callback
375:      * @return array
376:      */
377:     function array_sort($array, Closure $callback)
378:     {
379:         return Illuminate\Support\Collection::make($array)->sortBy($callback)->all();
380:     }
381: }
382: 
383: if ( ! function_exists('asset'))
384: {
385:     /**
386:      * Generate an asset path for the application.
387:      *
388:      * @param  string  $path
389:      * @param  bool    $secure
390:      * @return string
391:      */
392:     function asset($path, $secure = null)
393:     {
394:         return app('url')->asset($path, $secure);
395:     }
396: }
397: 
398: if ( ! function_exists('base_path'))
399: {
400:     /**
401:      * Get the path to the base of the install.
402:      *
403:      * @return string
404:      */
405:     function base_path()
406:     {
407:         return app()->make('path.base');
408:     }
409: }
410: 
411: if ( ! function_exists('camel_case'))
412: {
413:     /**
414:      * Convert a value to camel case.
415:      *
416:      * @param  string  $value
417:      * @return string
418:      */
419:     function camel_case($value)
420:     {
421:         return Illuminate\Support\Str::camel($value);
422:     }
423: }
424: 
425: if ( ! function_exists('class_basename'))
426: {
427:     /**
428:      * Get the class "basename" of the given object / class.
429:      *
430:      * @param  string|object  $class
431:      * @return string
432:      */
433:     function class_basename($class)
434:     {
435:         $class = is_object($class) ? get_class($class) : $class;
436: 
437:         return basename(str_replace('\\', '/', $class));
438:     }
439: }
440: 
441: if ( ! function_exists('csrf_token'))
442: {
443:     /**
444:      * Get the CSRF token value.
445:      *
446:      * @return string
447:      */
448:     function csrf_token()
449:     {
450:         $session = app('session');
451: 
452:         if (isset($session))
453:         {
454:             return $session->getToken();
455:         }
456:         else
457:         {
458:             throw new RuntimeException("Application session store not set.");
459:         }
460:     }
461: }
462: 
463: if ( ! function_exists('dd'))
464: {
465:     /**
466:      * Dump the passed variables and end the script.
467:      *
468:      * @param  dynamic  mixed
469:      * @return void
470:      */
471:     function dd()
472:     {
473:         array_map(function($x) { var_dump($x); }, func_get_args()); die;
474:     }
475: }
476: 
477: if ( ! function_exists('e'))
478: {
479:     /**
480:      * Escape HTML entities in a string.
481:      *
482:      * @param  string  $value
483:      * @return string
484:      */
485:     function e($value)
486:     {
487:         return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
488:     }
489: }
490: 
491: if ( ! function_exists('ends_with'))
492: {
493:     /**
494:      * Determine if a given string ends with a given needle.
495:      *
496:      * @param string $haystack
497:      * @param string|array $needle
498:      * @return bool
499:      */
500:     function ends_with($haystack, $needle)
501:     {
502:         return Illuminate\Support\Str::endsWith($haystack, $needle);
503:     }
504: }
505: 
506: if ( ! function_exists('head'))
507: {
508:     /**
509:      * Get the first element of an array. Useful for method chaining.
510:      *
511:      * @param  array  $array
512:      * @return mixed
513:      */
514:     function head($array)
515:     {
516:         return reset($array);
517:     }
518: }
519: 
520: if ( ! function_exists('link_to'))
521: {
522:     /**
523:      * Generate a HTML link.
524:      *
525:      * @param  string  $url
526:      * @param  string  $title
527:      * @param  array   $attributes
528:      * @param  bool    $secure
529:      * @return string
530:      */
531:     function link_to($url, $title = null, $attributes = array(), $secure = null)
532:     {
533:         return app('html')->link($url, $title, $attributes, $secure);
534:     }
535: }
536: 
537: if ( ! function_exists('last'))
538: {
539:     /**
540:      * Get the last element from an array.
541:      *
542:      * @param  array  $array
543:      * @return mixed
544:      */
545:     function last($array)
546:     {
547:         return end($array);
548:     }
549: }
550: 
551: if ( ! function_exists('link_to_asset'))
552: {
553:     /**
554:      * Generate a HTML link to an asset.
555:      *
556:      * @param  string  $url
557:      * @param  string  $title
558:      * @param  array   $attributes
559:      * @param  bool    $secure
560:      * @return string
561:      */
562:     function link_to_asset($url, $title = null, $attributes = array(), $secure = null)
563:     {
564:         return app('html')->linkAsset($url, $title, $attributes, $secure);
565:     }
566: }
567: 
568: if ( ! function_exists('link_to_route'))
569: {
570:     /**
571:      * Generate a HTML link to a named route.
572:      *
573:      * @param  string  $name
574:      * @param  string  $title
575:      * @param  array   $parameters
576:      * @param  array   $attributes
577:      * @return string
578:      */
579:     function link_to_route($name, $title = null, $parameters = array(), $attributes = array())
580:     {
581:         return app('html')->linkRoute($name, $title, $parameters, $attributes);
582:     }
583: }
584: 
585: if ( ! function_exists('link_to_action'))
586: {
587:     /**
588:      * Generate a HTML link to a controller action.
589:      *
590:      * @param  string  $action
591:      * @param  string  $title
592:      * @param  array   $parameters
593:      * @param  array   $attributes
594:      * @return string
595:      */
596:     function link_to_action($action, $title = null, $parameters = array(), $attributes = array())
597:     {
598:         return app('html')->linkAction($action, $title, $parameters, $attributes);
599:     }
600: }
601: 
602: if ( ! function_exists('object_get'))
603: {
604:     /**
605:      * Get an item from an object using "dot" notation.
606:      *
607:      * @param  object  $object
608:      * @param  string  $key
609:      * @param  mixed   $default
610:      * @return mixed
611:      */
612:     function object_get($object, $key, $default = null)
613:     {
614:         if (is_null($key)) return $object;
615:         
616:         foreach (explode('.', $key) as $segment)
617:         {
618:             if ( ! is_object($object) or ! isset($object->{$segment}))
619:             {
620:                 return value($default);
621:             }
622: 
623:             $object = $object->{$segment};
624:         }
625: 
626:         return $object;
627:     }
628: }
629: 
630: if ( ! function_exists('public_path'))
631: {
632:     /**
633:      * Get the path to the public folder.
634:      *
635:      * @return string
636:      */
637:     function public_path()
638:     {
639:         return app()->make('path.public');
640:     }
641: }
642: 
643: if ( ! function_exists('route'))
644: {
645:     /**
646:      * Generate a URL to a named route.
647:      *
648:      * @param  string  $route
649:      * @param  string  $parameters
650:      * @param  bool    $absolute
651:      * @return string
652:      */
653:     function route($route, $parameters = array(), $absolute = true)
654:     {
655:         return app('url')->route($route, $parameters, $absolute);
656:     }
657: }
658: 
659: if ( ! function_exists('secure_asset'))
660: {
661:     /**
662:      * Generate an asset path for the application.
663:      *
664:      * @param  string  $path
665:      * @return string
666:      */
667:     function secure_asset($path)
668:     {
669:         return asset($path, true);
670:     }
671: }
672: 
673: if ( ! function_exists('secure_url'))
674: {
675:     /**
676:      * Generate a HTTPS url for the application.
677:      *
678:      * @param  string  $path
679:      * @param  mixed   $parameters
680:      * @return string
681:      */
682:     function secure_url($path, $parameters = array())
683:     {
684:         return url($path, $parameters, true);
685:     }
686: }
687: 
688: if ( ! function_exists('snake_case'))
689: {
690:     /**
691:      * Convert a string to snake case.
692:      *
693:      * @param  string  $value
694:      * @param  string  $delimiter
695:      * @return string
696:      */
697:     function snake_case($value, $delimiter = '_')
698:     {
699:         return Illuminate\Support\Str::snake($value, $delimiter);
700:     }
701: }
702: 
703: if ( ! function_exists('starts_with'))
704: {
705:     /**
706:      * Determine if a string starts with a given needle.
707:      *
708:      * @param  string  $haystack
709:      * @param  string|array  $needle
710:      * @return bool
711:      */
712:     function starts_with($haystack, $needle)
713:     {
714:         return Illuminate\Support\Str::startsWith($haystack, $needle);
715:     }
716: }
717: 
718: if ( ! function_exists('storage_path'))
719: {
720:     /**
721:      * Get the path to the storage folder.
722:      *
723:      * @return  string
724:      */
725:     function storage_path()
726:     {
727:         return app('path.storage');
728:     }
729: }
730: 
731: if ( ! function_exists('str_contains'))
732: {
733:     /**
734:      * Determine if a given string contains a given sub-string.
735:      *
736:      * @param  string        $haystack
737:      * @param  string|array  $needle
738:      * @return bool
739:      */
740:     function str_contains($haystack, $needle)
741:     {
742:         return Illuminate\Support\Str::contains($haystack, $needle);
743:     }
744: }
745: 
746: if ( ! function_exists('str_finish'))
747: {
748:     /**
749:      * Cap a string with a single instance of a given value.
750:      *
751:      * @param  string  $value
752:      * @param  string  $cap
753:      * @return string
754:      */
755:     function str_finish($value, $cap)
756:     {
757:         return Illuminate\Support\Str::finish($value, $cap);
758:     }
759: }
760: 
761: if ( ! function_exists('str_is'))
762: {
763:     /**
764:      * Determine if a given string matches a given pattern.
765:      *
766:      * @param  string  $pattern
767:      * @param  string  $value
768:      * @return bool
769:      */
770:     function str_is($pattern, $value)
771:     {
772:         return Illuminate\Support\Str::is($pattern, $value);
773:     }
774: }
775: 
776: if ( ! function_exists('str_plural'))
777: {
778:     /**
779:      * Get the plural form of an English word.
780:      *
781:      * @param  string  $value
782:      * @param  int  $count
783:      * @return string
784:      */
785:     function str_plural($value, $count = 2)
786:     {
787:         return Illuminate\Support\Str::plural($value, $count);
788:     }
789: }
790: 
791: if ( ! function_exists('str_random'))
792: {
793:     /**
794:      * Generate a "random" alpha-numeric string.
795:      *
796:      * Should not be considered sufficient for cryptography, etc.
797:      *
798:      * @param  int     $length
799:      * @return string
800:      */
801:     function str_random($length = 16)
802:     {
803:         return Illuminate\Support\Str::random($length);
804:     }
805: }
806: 
807: if ( ! function_exists('str_singular'))
808: {
809:     /**
810:      * Get the singular form of an English word.
811:      *
812:      * @param  string  $value
813:      * @return string
814:      */
815:     function str_singular($value)
816:     {
817:         return Illuminate\Support\Str::singular($value);
818:     }
819: }
820: 
821: if ( ! function_exists('studly_case'))
822: {
823:     /**
824:      * Convert a value to studly caps case.
825:      *
826:      * @param  string  $value
827:      * @return string
828:      */
829:     function studly_case($value)
830:     {
831:         return Illuminate\Support\Str::studly($value);
832:     }
833: }
834: 
835: if ( ! function_exists('trans'))
836: {
837:     /**
838:      * Translate the given message.
839:      *
840:      * @param  string  $id
841:      * @param  array   $parameters
842:      * @param  string  $domain
843:      * @param  string  $locale
844:      * @return string
845:      */
846:     function trans($id, $parameters = array(), $domain = 'messages', $locale = null)
847:     {
848:         return app('translator')->trans($id, $parameters, $domain, $locale);
849:     }
850: }
851: 
852: if ( ! function_exists('trans_choice'))
853: {
854:     /**
855:      * Translates the given message based on a count.
856:      *
857:      * @param  string  $id
858:      * @param  int     $number
859:      * @param  array   $parameters
860:      * @param  string  $domain
861:      * @param  string  $locale
862:      * @return string
863:      */
864:     function trans_choice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
865:     {
866:         return app('translator')->transChoice($id, $number, $parameters, $domain, $locale);
867:     }
868: }
869: 
870: if ( ! function_exists('url'))
871: {
872:     /**
873:      * Generate a url for the application.
874:      *
875:      * @param  string  $path
876:      * @param  mixed   $parameters
877:      * @param  bool    $secure
878:      * @return string
879:      */
880:     function url($path = null, $parameters = array(), $secure = null)
881:     {
882:         return app('url')->to($path, $parameters, $secure);
883:     }
884: }
885: 
886: if ( ! function_exists('value'))
887: {
888:     /**
889:      * Return the default value of the given value.
890:      *
891:      * @param  mixed  $value
892:      * @return mixed
893:      */
894:     function value($value)
895:     {
896:         return $value instanceof Closure ? $value() : $value;
897:     }
898: }
899: 
900: if ( ! function_exists('with'))
901: {
902:     /**
903:      * Return the given object. Useful for chaining.
904:      *
905:      * @param  mixed  $object
906:      * @return mixed
907:      */
908:     function with($object)
909:     {
910:         return $object;
911:     }
912: }
913: 
cart API documentation generated by ApiGen 2.8.0