PackModel.php 803 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Models\Mysql;
  3. use App\Models\Mongo\AgentAttrsLogsModel;
  4. use Carbon\Carbon;
  5. use Illuminate\Support\Facades\DB;
  6. class PackModel extends BaseMysql
  7. {
  8. protected $table = 'app_pack';
  9. /**
  10. * UUID 键名
  11. * @var string
  12. */
  13. protected $uuidKeyName = 'uid';
  14. protected $appends = [];
  15. /**
  16. * The "booted" method of the model.
  17. *
  18. * @return void
  19. */
  20. protected static function boot()
  21. {
  22. parent::boot();
  23. self::creating(function ($model) {
  24. $model->{$model->uuidKeyName} = self::generateId($model->uuidKeyName);
  25. });
  26. self::created(function ($model) {
  27. $uuid = hashEncodeId($model->id);
  28. $model->{$model->uuidKeyName} = $uuid;
  29. $model->save();
  30. });
  31. }
  32. }