承接 unckleg/laravel-helpers 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

unckleg/laravel-helpers

Composer 安装命令:

composer require unckleg/laravel-helpers

包简介

Laravel helpers package lets you use and create custom view/action helpers.

README 文档

README

View & Action Helpers

Version License

Laravel helpers package lets you use and create custom view/action helpers.

Installation

Pull package:

composer require unckleg/laravel-helpers

Register service provider in config/app

...
Unckleg\Helpers\HelpersServiceProvider::class,

Example

Create app/Helpers directory or run command:

php artisan make:helper Hello --type=View
  • Hello - Name of View Helper
  • type - View or Action

Command will create directory and Helper for you.

  • Helper
<?php

namespace App\Helpers;

class Test
{
    /**
     *
     * Blade calling: @test::helloWorld()
     *
     * @return string
     */
    public function helloWorld()
    {
        return 'Hello world';
    }

    /**
     *
     * Blade calling: @test::helloTo(array $people)
     *
     * @param  array  $people
     * @return string
     */
    public function helloTo(array $people)
    {
        return implode(', ', $people);
    }
    
    /**
     * 
     * Blade calling: @test::navigation()
     *
     * @return string   
     */
    public static function navigation() 
    { 
        $pages = App\Page::all();    
    ?>
        
        <div class="navigation">
            <ul> 
                @foreach($pages as $page)
                    <li> 
                        <a href="{{ Url::slugify(app()->baseUrl($page->title)) }}"> 
                            {{ $page->title }} 
                        </a>
                    </li>
                @endforeach
            </ul>
        </div>

    <?php }
}
  • In blade
@test:helloWorld()
// outputs: Hello world

@test::helloTo(['One', 'Two', 'Three', 'Four', 'Five'])
// outputs: One, Two, Three, Four, Five

@test::navigation()
// outputs: This will output whole html provided in navigation method

Built-in helpers

  • @javascripts()  @includeJs()    @endjavascripts()
  • @stylesheets() @includeCss() @endstylesheets()
  • @routeName()

Notes

If you experience permission error while using commands make sure you grant permissions for Helpers directory.

统计信息

  • 总下载量: 221
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固