| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Models\Mysql;
- use App\Models\Mongo\AgentAttrsLogsModel;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\DB;
- class PackModel extends BaseMysql
- {
- protected $table = 'app_pack';
- /**
- * UUID 键名
- * @var string
- */
- protected $uuidKeyName = 'uid';
- protected $appends = [];
- /**
- * The "booted" method of the model.
- *
- * @return void
- */
- protected static function boot()
- {
- parent::boot();
- self::creating(function ($model) {
- $model->{$model->uuidKeyName} = self::generateId($model->uuidKeyName);
- });
- self::created(function ($model) {
- $uuid = hashEncodeId($model->id);
- $model->{$model->uuidKeyName} = $uuid;
- $model->save();
- });
- }
- }
|