macrominds/laravel-choice 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

macrominds/laravel-choice

Composer 安装命令:

composer require macrominds/laravel-choice

包简介

A modal choice dialogue for laravel

README 文档

README

If you have an action that needs to be confirmed before proceeding, or you want to let the user choose from multiple options, then this solution might just be exactly what you are looking for.

Example

The user has chosen to delete a person. That means that all upcoming events, hosted by this person, need to be canceled. But you don't want to cancel them silently. You want to be polite and ask the user first:

Screenshot of a modal choice dialogue implemented with macrominds/laravel-choice

Simply return the Choice where you would normally return the redirect() in your Controller.

return Choice::make(
    'Deleting the person will cancel some events',
    sprintf(
        '%s events are going to be canceled if you delete %s',
        $numEvents, $personName
    ),
    [
        Option::makeCancel('Cancel deletion'),
        Option::make(
            'Delete person and cancel events',
            route('customer.force-destroy', ['person' => $person]),
            'DELETE',
            [],
            true),
    ]
);

Depending on the choice of the user, she will be redirected either back to the previous page (standard Option::makeCancel behaviour) or to any route of your liking. You are not limited to two options.

Installation

composer require macrominds/laravel-choice.

Usage

You should call php artisan vendor:publish --tag=laravel-choice.

This will add the customizable views to resources/views/vendor/choice/* and the minimalistic styling resources/assets/sass/vendor/choice/_choice.scss to your project. You should @import "vendor/choice/choice"; in your app.scss afterwards.

In your master blade view, below all visible page elements, just before the end of your </body> or just before the <script>s at the bottom, add the following line:

{{ macrominds\laravel\choice\Choice::render() }}

Next? Nothing. You are ready to go. Just replace a return redirect() statement in your Controller with return Choice::make (//....

TODO

  • Add some documentation
  • Make php5.6 compatible

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固