Helpers

Other topics

Array methods

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

camel_case()

This method changes a string to camel case

camel_case('hello_world');

result

HelloWorld

Path mehods

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

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();

Contributors

Topic Id: 8827

Example Ids: 27502,27503,27504,27505

This site is not affiliated with any of the contributors.