In this tutorial we’re going to learn how to do first letter capital from string. Follow this tutorial i have mentioned in very easy way to capitalize in laravel. The Str::ucfirst() method in Laravel is used to make the first character of a string uppercase. It is a convenient method to capitalize the first character of a string.
1st step go to your controller and put below function
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$inputString = "my name in amit kumar thakur"
$title = ucfirst($inputString);
return view('your_page_name',compact('$title');
}
}
2nd step go to blade page and put below code as well
Blade File Code:
<!DOCTYPE html>
<html>
<head>
<title>Capitalize String Title</title>
</head>
<body>
<h1>Capitalize String in laravel</h1>
<p>{{ $uniqueTitle }}</p>
</body>
</html>
Output : –
My name in amit kumar thakur