Arrays
array_add($array, 'key', 'value'); array_build($array, function(){}); array_divide($array); array_dot($array); array_except($array, ['key']); array_fetch($array, 'key'); array_first($array, function($key, $value){}, $default); // Strips keys from the arrayarray_flatten($array); array_forget($array, 'foo'); // Dot notationarray_forget($array, 'foo.bar'); array_get($array, 'foo', 'default'); array_get($array, 'foo.bar', 'default'); array_only($array, ['key']); // Return array of key => valuesarray_pluck($array, 'key'); // Return and remove 'key' from arrayarray_pull($array, 'key'); array_set($array, 'key', 'value'); // Dot notationarray_set($array, 'key.subkey', 'value'); array_sort($array, function(){}); // First element of an arrayhead($array); // Last element of an arraylast($array);
Paths
app_path(); public_path(); // App root pathbase_path(); storage_path();
Strings
camel_case($value); class_basename($class); // Escape a stringe('<html>'); starts_with('Foo bar.', 'Foo'); ends_with('Foo bar.', 'bar.'); snake_case('fooBar'); str_contains('Hello foo bar.', 'foo'); // Result: foo/bar/str_finish('foo/bar', '/'); str_is('foo*', 'foobar'); str_plural('car'); str_random(25); str_singular('cars'); // Result: FooBarstudly_case('foo_bar'); trans('foo.bar'); trans_choice('foo.bar', $count);
URLs and Links
action('FooController@method', $parameters); link_to('foo/bar', $title, $attributes, $secure); link_to_asset('img/foo.jpg', $title, $attributes, $secure); link_to_route('route.name', $title, $parameters, $attributes); link_to_action('FooController@method', $title, $params, $attrs); // HTML Linkasset('img/photo.jpg', $title, $attributes); // HTTPS linksecure_asset('img/photo.jpg', $title, $attributes); secure_url('path', $parameters); route($route, $parameters, $absolute = true); url('path', $parameters = [], $secure = null);
Miscellaneous
csrf_token(); dd($value); value(function(){ return 'bar'; }); with(new Foo)->chainedMethod();
No comments:
Post a Comment