Files
vuefilemanager/app/Models/Share.php
Peter Papp b7e1be7518 - implement factories into models
- Model class refactored in relations
2021-02-26 17:57:21 +01:00

44 lines
808 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Str;
class Share extends Model
{
use Notifiable, HasFactory;
protected $guarded = ['id'];
protected $appends = ['link'];
public $incrementing = false;
protected $keyType = 'string';
/**
* Generate share link
*
* @return string
*/
public function getLinkAttribute()
{
return url('/shared', ['token' => $this->attributes['token']]);
}
/**
* Model events
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->id = (string)Str::uuid();
});
}
}