Posts

Showing posts from January, 2025

I added custom class for the last row of grid with checking loop count

@forelse ( $activeAreaGuides as $activeAreaGuide )     < div class = "col-xl-4 col-md-6" >         < div             class = "th-team team-grid             {{ $loop -> remaining < ( $loop -> count % 3 == 0 ? 3 : $loop -> count % 3 )                 ? 'custom-margin-last-row'                 : 'custom-margin-team-grid' }} " >             < div class = "team-img2" >                 < img src = " {{ env ('FILESYSTEM_URL') . $activeAreaGuide -> photograph }} " >             </ div >             < div class = "team-content" >                 < div class = "media-body" >   ...

Creating new helper function in laravel 11

  1. Create a Helper File Create a new PHP file to store your helper functions. Laravel doesn't come with a dedicated helper file by default, but you can create one in the app/Helpers directory (or any directory you prefer). Example: bash Copy code mkdir app/Helpers touch app/Helpers/helpers.php 2. Define Your Helper Function Add your function(s) to the new helper file. Example ( app/Helpers/helpers.php ): php Copy code <?php if (! function_exists ( 'greetUser' )) { function greetUser ( $name ) { return "Hello, $name !" ; } } 3. Include the Helper File You need to include this file in the application so that Laravel can load the functions. Option 1: Autoload via composer.json Edit your composer.json file and add the helper file under the autoload section: json Copy code "autoload" : { "files" : [ "app/Helpers/helpers.php" ] } After adding this, run the following command to regenerate...