Laravel

Laravel TutorialChange default routing behaviour in Laravel 5.2.31 +CustomException class in LaravelDeploy Laravel 5 App on Shared Hosting on Linux ServerLaravel ArtisanLaravel AuthenticationLaravel AuthorizationLaravel Blade TemplatesLaravel CashierLaravel CollectionsLaravel Common Issues & Quick FixesLaravel ConstantsLaravel ControllersLaravel Cron basicsLaravel Cross Domain RequestLaravel Custom Helper functionLaravel DatabaseLaravel Database MigrationsLaravel Database SeedingLaravel Directory StructureLaravel DockerLaravel EloquentLaravel Eloquent : RelationshipLaravel Eloquent: Accessors & MutatorsLaravel Eloquent: ModelLaravel Error HandlingLaravel Events and ListenersLaravel Filesystem / Cloud StorageLaravel Form Request(s)Laravel Getting started with laravel-5.3Laravel HelpersLaravel HTML and Form BuilderLaravel InstallationLaravel Installation GuideLaravel Introduction to laravel-5.2Laravel Introduction to laravel-5.3Laravel lumen frameworkLaravel Macros in Eloquent RelationshipLaravel MailLaravel MiddlewareLaravel ObserverLaravel PackagesLaravel PaginationLaravel Permissions for storageLaravel PoliciesLaravel QueuesLaravel RequestsLaravel Route Model BindingLaravel RoutingLaravel SeedingLaravel ServicesLaravel SocialiteLaravel Task SchedulingLaravel TestingLaravel Token Mismatch Error in AJAXLaravel use fields aliases in EloquentLaravel Useful linksLaravel ValetLaravel ValidationMultiple DB Connections in LaravelNaming Files when uploading with Laravel on WindowsRemove public from URL in laravelSparkpost integration with Laravel 5.4



Laravel Helpers

From WikiOD

Laravel helpers are the globally accessible functions defined by the framework. It can be directly called and independently used anywhere within the application without needing to instantiating an object or importing class.

There are helpers for manipulating Arrays, Paths, Strings, URLs, etc

Array methods[edit | edit source]

array_add()

This method is used to add new key value pairs to an array.

$array = ['username' => 'testuser'];

$array = array_add($array, 'age', 18);

result

['username' => 'testuser', 'age' => 18]

String methods[edit | edit source]

camel_case()

This method changes a string to camel case

camel_case('hello_world');

result

HelloWorld

Path mehods[edit | edit source]

Path methods helps easy access to application related paths easily from anywhere.

public_path()

This method returns the fully qualified public path of the application. which is the public directory.

$path = public_path();

Urls[edit | edit source]

url()

The url function generates a fully qualified URL to the given path.

if your site is hello.com

echo url('my/dashboard');

would return

hello.com/my/dashboard

if nothing is passed to the url method it would return an instance of Illuminate\Routing\UrlGenerator, and it could be used like this

would return current url

echo url()->current();

would return full url

echo url()->full();

would return previous url

echo url()->previous();

Credit:Stack_Overflow_Documentation