PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Nahidul Hasan   Laravel Macro Example   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Laravel Macro Example
Example of macro service to use in view templates
Author: By
Last change:
Date: 1 year ago
Size: 1,771 bytes
 

Contents

Class file image Download

Laravel-Macros

Latest Stable Version Total Downloads Latest Unstable Version License

> A Simple package for using Macros in Laravel

Installation

Requirements

- PHP >= 5.6.4 - Laravel >= 5.5

Installing

Run the following commands

composer require nahidulhasan/laravel-macros

php artisan vendor:publish

Basic Usage

A new class is created in App/Services folder named Macros.php. Here you have to add your code.

For example, I have added bank list.

Now you can call Form::selectBank() in any view, and have it display a nice list of Bank list to select from.

You can specify the parameters as the input name, default selected value, and array of options.

Here is the example :

<div class="form-group">

<label for="bank_name">Bank Name</label>

{{ Form::selectBank("bank_name", $merchant['paymentInfo']->bank_name ?? null,["class"=>"form-control"]) }}

</div>

If you want to learn more about macros and want to configure without using package, please read this blog

License

Laravel-Macros for Laravel is open-sourced software licensed under the MIT license