diff options
Diffstat (limited to 'app/Rugby/Model/Video.php')
-rw-r--r-- | app/Rugby/Model/Video.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/Rugby/Model/Video.php b/app/Rugby/Model/Video.php new file mode 100644 index 0000000..2182b65 --- /dev/null +++ b/app/Rugby/Model/Video.php @@ -0,0 +1,34 @@ +<?php + +namespace App\Rugby\Model; + +use App\Rugby\Model\Match; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Storage; + +class Video extends Model +{ + protected $table = 'videos'; + protected $casts = ['date' => 'datetime:Y-m-d']; + protected $fillable = ['path']; + + public function match() + { + return $this->belongsTo(Match::class); + } + + public function getFilename(): string + { + $parts = explode('/', $this->path); + + return $parts[count($parts) - 1]; + } + + public function getUrl(): string + { + return asset('storage/matches/' . $this->getFilename()); + // return Storage::disk('local')->url( + // 'matches/' . $this->getFilename() + // ); + } +} |