tonning/flashable

一个简单的特性,用于在模型事件触发时闪烁,如 `created`、`updated` 和 `saved`。

1.1.1 2020-03-20 16:49 UTC

This package is auto-updated.

Last update: 2024-08-29 04:25:38 UTC


README

一个简单的特性,用于在模型事件触发时闪烁,如 createdupdatedsaved。使用 Jeffrey Way 的优秀 Flash 包来实际显示闪烁信息。

安装

首先通过 Composer 拉取该包。

composer require tonning/flashable

然后,将特性添加到您希望在 CRUD 操作上自动闪烁的模型。

use Tonning\Flashable\Flashable;

class Post extends Model
{
    use Flashable;
    
    ...
}

自定义

您可以通过在模型中添加一个 getModelName 方法来指定模型的名称。

public function getModelName() {
  return 'Blog post';
}

为了实现更精细的控制,您可以在模型上添加一个受保护的属性。

protected $flashable = [
  'created' => 'Your blog post have been created. Good job!',
  'updated' => 'I hope nobody saw those mistakes...',
  'deleted' => 'Be gone blog post!'
]