承接 mujhtech/nav-toastr 相关项目开发

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

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

mujhtech/nav-toastr

Composer 安装命令:

composer require mujhtech/nav-toastr

包简介

nav-toastr flash notification with custom redirection for laravel app

README 文档

README

👀 This package helps you to add Toast.js notifications to your Laravel app

Latest Stable Version Latest Unstable Version Build Status Scrutinizer Code Quality Code Coverage Total Downloads License

Install

You can install the package using composer

$ composer require mujhtech/nav-toastr

Then add the service provider to config/app.php. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.

'providers' => [
    ...
    Mujhtech\NavToastr\NavToastrServiceProvider::class
    ...
];

To install the configuration and assets file run:

$ php artisan navtoastr:install"

Usage:

Include [app.css] and app.js in your view template:

  1. Link to app.css <link href="src/Toast.css" rel="stylesheet"/> or @navtoastrCss

  2. Link to app.js <script src="src/Toast.js"></script> or @navtoastrJs

  3. use navtoastr() helper function inside your controller to set a toast notification for info, success, warning or error

// Display an info toast with no title
navtoastr()->info('Are you the 6 fingered man?')

as an example:

<?php

namespace App\Http\Controllers;

use App\User;
use App\Http\Requests\PostRequest;
use Illuminate\Database\Eloquent\Model;

class UserController extends Controller
{
    public function store(UserRequest $request)
    {
        $post = User::create($request->only(['username', 'password']));

        if ($post instanceof Model) {

            navtoastr()->success('Data has been saved successfully!');

            return navtoastr()->named('posts.index');
        }

        navtoastr()->error('An error has occurred please try again later.');

        return navtoastr()->back();
    }
}

After that add the @navtoastrRender at the bottom of your view to actualy render the nav-toastr notifications.

<!doctype html>
<html>
    <head>
        <title>Nav Toastr.js</title>
        @navtoastrCss
    </head>
    <body>
        
    </body>
    @navtoastrJs
    @navtoastrRender
</html>

Other Options

// Set a info toast
navtoastr()->info('My name is Muhideen Mujeeb')

// Set a success toast
navtoastr()->success('Have fun storming the castle!')

// Set an error toast
navtoastr()->error('I do not think that word means what you think it means.')

// Set an warning toast

navtoastr()->warning('We do have the Kapua suite available.')

Other api methods:

// You can also chain multiple messages together using method chaining

navtoastr()->info('Are you the 6 fingered man?')->success('Have fun storming the castle!')->warning('doritos');

// you could replace @navtoastrRender by :

navtoastr()->render() or app('nav-toastr')->render()

// you can use navtoastr('') instead of navtoastr()->success()

function toastr(string $message = null, string $type = 'success', string $title = '', bool $enableCustomButton = false);

so

  • navtoastr($message) is equivalent to navtoastr()->success($message)
  • navtoastr($message, 'info', true) is equivalent to navtoastr()->info($message, true)
  • navtoastr($message, 'warning', true) is equivalent to navtoastr()->warning($message, true)
  • navtoastr($message, 'error', false) is equivalent to navtoastr()->error($message, false)

configuration:

// config/nav-toastr.php
<?php

return [
    
    'custombuttons' => [
        [
            'text'      => 'Refresh the page',
            'reload'    => true
        ],
        [
            'text'      => 'My Website',
            'url'       => 'https://mujh.tech'
        ],
        [
            'text'      => 'Twitter',
            'url'       => 'https://twitter.com/mujhtech'
        ]
    ],
];

Credits

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固