- added model events for generate uuid

This commit is contained in:
Peter Papp
2021-02-26 17:19:57 +01:00
parent fd02fbfe08
commit 920ee19651
25 changed files with 175 additions and 348 deletions
+22 -21
View File
@@ -3,28 +3,29 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
/**
* App\Traffic
*
* @property int $id
* @property int $user_id
* @property int $upload
* @property int $download
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|Traffic newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Traffic newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Traffic query()
* @method static \Illuminate\Database\Eloquent\Builder|Traffic whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Traffic whereDownload($value)
* @method static \Illuminate\Database\Eloquent\Builder|Traffic whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Traffic whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|Traffic whereUpload($value)
* @method static \Illuminate\Database\Eloquent\Builder|Traffic whereUserId($value)
* @mixin \Eloquent
*/
class Traffic extends Model
{
protected $fillable = ['user_id', 'upload', 'download'];
protected $fillable = [
'user_id',
'upload',
'download'
];
public $incrementing = false;
protected $keyType = 'string';
/**
* Model events
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->id = (string)Str::uuid();
});
}
}