Created
June 20, 2019 11:11
-
-
Save ManojKiranA/07ac510ed47990ccaa3701d07b68bced to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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