diff options
author | Fbenas <philbeansburton@gmail.com> | 2020-06-20 21:07:45 +0100 |
---|---|---|
committer | Fbenas <philbeansburton@gmail.com> | 2020-06-20 21:07:45 +0100 |
commit | 8d6e8b306d7836e4075a13ad98617bfe5afaa1a0 (patch) | |
tree | 99c44e28da231cac0d9e513aabc1ee0768972426 /app/Rugby/Model/Video.php | |
parent | 897b68ac107f2fb0d4dc1d31ce96ce24c862eb27 (diff) |
Add new scripts for youtube downloading and syncing with existing matches
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() + // ); + } +} |