lo jazone/helper

包含辅助混合器的包

安装: 0

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 1

分支: 0

语言:HTML

dev-master 2020-04-24 03:01 UTC

This package is auto-updated.

Last update: 2024-09-24 12:57:51 UTC


README

辅助工具

Laravel 5.8 需要 bootstrap 4.4.1 min 可选 font awesome 5.13.0 min

安装和配置
  • 运行命令

      composer require lojazone/helper
    
  • 添加到 config/app.php

      'providers' => [
          ...
          /*
           * Package Service Providers...
           */
          Lojazone\Helper\Providers\HelperServiceProvider::class,
          ...
      ],
      
      'aliases' => [
          ...
          'Helper' => \Lojazone\Helper\Support\Helper::class,
      ]
    
将混合辅助器添加到帮助
* mix_url
* isActive
* messages
* listDir
mix_url

此函数用于使用 Laravel Mix 编译创建基本 URL

如何使用

 <link rel="stylesheet" href="{{ Helper::mix_url('css/app.css') }}">
 
 Usage to create base url from compiling files with laravel-mix  
isActive

此函数用于根据链接是否激活添加 CSS 类到代码

如何使用

<a href="{{ route('blog.index') }}" class="{{ isActive('blog.index', 'my_class_active') }}">Blog</a>

'my_class_active' class is optional or to use another class name.
messages

此函数用于使用 Bootstrap 的类型类在会话中创建消息

如何在请求错误之前使用消息

All messages from session:

@include('helper::partials.session_message')

或者

Message to input especific:

<div class="col-12 col-md-6">
    <div class="form-group">
     <label for="first_name" class="required">First Name</label>
     <input type="text" name="first_name" id="first_name" class="form-control {{ $errors->has('first_name') ? 'is-invalid' : '' }}">
     <span class="d-block">@include('helper::partials.invalid_message', ['input' => 'first_name'])</span>
    </div>
</div>    

如何使用 Helper::message(...) 创建的消息

include before call js bootstrap:

@include('helper::partials.notify_message')


Call this funcition with types = success, primary, info, warning or danger:

Helper::messages('Welcome', "Last login in " . now()->format('d M Y H:i'), 'success', 2000);
Helper::messages('Welcome', "Last login in " . now()->format('d M Y H:i'), 'primary', 3000);
Helper::messages('Welcome', "Last login in " . now()->format('d M Y H:i'), 'info', 4000);
Helper::messages('Welcome', "Last login in " . now()->format('d M Y H:i'), 'warning', 5000);
Helper::messages('Welcome', "Last login in " . now()->format('d M Y H:i'), 'danger', 6000);
listDir

此函数用于列出指定目录中的文件