How To Convert Any Laravel String Into Pascal Case String

Laravel String Support library gives us opportunity to use it in different ways and achieve many feats with unique methods. We have mentioned the conversion of any string into Pascal Case String in Laravel.

Raw string: store products count

Pascal Case String: StoreProductsCount

Laravel Str support library shows us how we can manipulate strings in unique ways with examples.  We can simply convert any string to Pascal Case using studly() function. Please see below the code we have done for you to understand it.

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Str;


class HomeController extends Controller {
	/**
	 * Show the application dashboard.
	 *
	 * @return \Illuminate\Contracts\Support\Renderable
	 */
	public function index() {
		$str = 'store products count';
		$converted = Str::studly($str);
		echo $converted;
	}
}

Please check Laravel 8.0 docs for detailed documentation. If you have any problem just leave a comment in comments section. We will answer it.