承接 tsungsoft/error-message 相关项目开发

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

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

tsungsoft/error-message

最新稳定版本:0.0.3

Composer 安装命令:

composer require tsungsoft/error-message

包简介

A Laravel Nova field.

README 文档

README

When throwing exception will display our actual message but only works on local environment and debug is true. if using this on production environment and debug is false it will always showing Server Error

but on the other hand using ValidationException, it will show "There was a problem submitting the form." and there is no way to show our message to the user ( as far as i know).

using this will ada new field on the form but only showing it when have error message.

Installation

using packagist

composer require tsungsoft/error-message

using github repository add this on composer.json

"require": {
    "tsungsoft/error-message": "*"
}
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/anditsung/laravel-nova-error-message"
    }
],

Usage

on Nova Resource

use Tsungsoft\ErrorMessage\ErrorMessage;

...

public function fields(Request $request)
{
    return [
        ...

        ErrorMessage::make('Error'),            // 'Error' -> must have the same value on ValidationException
        
        ...
    ];
}

...

on Model

...

private static function validationError($message)
{
    $messageBag = new MessageBag;
    $messageBag->add('error', __($message));    // 'error' -> must have the same value when creating the field on nova resource

    throw ValidationException::withMessages($messageBag->getMessages());
}

protected static function boot()
{
    parent::boot();

    static::creating(function($user) {

        ...

        self::validationError("You have an error");

        ...

    });

    static::updating(function($user) {
    
        ...

        self::validationError("You have an error");

        ...

    });
}

...

Create User

Update User

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-31