In this video we are going to learn about Fluent Strings.
Fluent strings provide a more fluent, object-oriented interface for working with string values,
allowing you to chain multiple string operations together using a more readable syntax compared to traditional string operations.
There are many Fulent Strings Operations.
I am going to show you some of them.
First of all lets Create a new controller.
So switch to the command prompt and here just type.

php artisan make:controller TestController.

Now goto the TestController.
and just create a function.

public function index()
{
echo '<h1> Fluent Strings</h1>';
}

Now create a route.
So goto the web.php file and here just type.

Route::get('test',[TestController::class ,'index']);

Alright now lets see the some of the Fulent Strings Operations.
So Start with after.
The after method returns everything after the given value in a string. For example.

$slice = Str::of('Welcome to my YouTube Channel')->after('Welcome to');
echo $slice;


This after method returns everything after Welcome to.
So it will return my YouTube Channel.
Lets check so goto the browser and just.
Add into url /test and press enter.
You can see here my YouTube Channel.
Now let see the afterlast.
The afterLast method returns everything after the last occurrence of the given value in a string.


$slice = Str::of('App\\Http\\Controllers\\Controller')->afterLast('\\\\');
echo $slice;


Here in this string there are 3 slashes.
So afterLast method just return the this string.
Because this is last slash ok.
Lets check just refresh the page.
You can see.
Its showing only controller ok.

Next method is append.
The append method appends the given values to the string:


$string = Str::of('Hello')->append(' Wolrd');
echo $string;


This append method just append these two string Hello and World ok.
Lets check, just refresh the page you can see here the string World is appended with Hello.

Now lets see the lower.
The lower method converts the given string to lowercase:.


$result = Str::of('LARAVEL')->lower();
echo $result;


Also import Str on top as following

use Illuminate\\Support\\Str;


Lets check.
You can see here the string is in lower case.
Next method is Replace.
The replace method replaces a given string within the string:


$replaced = Str::of('Laravel 7.x')->replace('7.x', '8.x');
echo $replaced;

You can see here 7.x replaced with 8.x.
Next method is title.
The title method converts the given string to Title Case.


$converted = Str::of('this is a title')->title();
echo $converted;


You can see here the string are now in title case.
Now let see the Slug method.
The slug method generates a URL friendly \"slug\" from the given string.


$slug = Str::of('Laravel Framework')->slug('-');
echo $slug;


You can see the now this is a slug ok.
Nex method is substr.
The substr method returns the portion of the string specified by the given start and length parameters:.


$string = Str::of('Laravel Framework')->substr(8);
echo $string;
$string = Str::of('Laravel Framework')->substr(8, 5);
echo $string;


You can see Framework and Frame Next method is trim.
The trim method trims the given string:


$string = Str::of('/Laravel/')->trim('/');
echo $string;


You can see her the result.
Now let see the upper method.
The upper method converts the given string to uppercase:.

$adjusted = Str::of('laravel')->upper();
echo $adjusted;


You and see here the the larevel text in upper case ok.
So in this way you can use Fluent string in laravel 8.