blob: 48da15efe0ce9e7d53f2fc93e10259a2ef6019ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?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', 'url'];
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());
}
}
|