Skip to content

Instantly share code, notes, and snippets.

@ManojKiranA
Created June 20, 2019 11:11
Show Gist options
  • Save ManojKiranA/07ac510ed47990ccaa3701d07b68bced to your computer and use it in GitHub Desktop.
Save ManojKiranA/07ac510ed47990ccaa3701d07b68bced to your computer and use it in GitHub Desktop.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Collective\Html\{FormFacade as Form , HtmlFacade as Html};
class FormMacroServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
Form::macro( 'selectMonthShort',
function (string $name, $selected = null, array $selAttr = [], array $optAttr = [], array $optGrpAttr = [], string $viFm = '%B', string $stFm = '%b', int $monthStart = 1, int $monthEnd = 12) {
$monthList = range($monthStart, $monthEnd);
foreach ($monthList as $mKey => $mValue) {
// $monthArray[strftime($stFm, mktime(0, 0, 0, $mValue, 1))] = strftime($viFm, mktime(0, 0, 0, $mValue, 1));
$monthArray[ $mValue] = strftime($viFm, mktime(0, 0, 0, $mValue, 1));
}
$monthArray = [null => 'Choose Month'] + $monthArray;
return $this->select($name, $monthArray, $selected, $selAttr, $optAttr, $optGrpAttr);
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment