2016-09-02 21:27:50 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
|
|
|
|
class Photo extends Model
|
|
|
|
{
|
|
|
|
use Notifiable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
2016-09-02 22:18:40 +01:00
|
|
|
'album_id',
|
|
|
|
'name',
|
|
|
|
'description',
|
|
|
|
'file_name',
|
2016-09-06 19:47:25 +01:00
|
|
|
'storage_file_name',
|
2016-09-02 22:18:40 +01:00
|
|
|
'mime_type',
|
|
|
|
'file_size',
|
|
|
|
'metadata_version',
|
|
|
|
'taken_at',
|
|
|
|
'camera_make',
|
|
|
|
'camera_model',
|
2016-09-03 17:09:49 +01:00
|
|
|
'camera_software',
|
|
|
|
'width',
|
2016-09-08 23:22:29 +01:00
|
|
|
'height',
|
|
|
|
'is_analysed'
|
2016-09-02 21:27:50 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be hidden for arrays.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $hidden = [
|
|
|
|
];
|
|
|
|
|
|
|
|
public function album()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Album::class);
|
|
|
|
}
|
2016-09-04 21:59:32 +01:00
|
|
|
|
2016-09-05 14:27:20 +01:00
|
|
|
public function thumbnailUrl($thumbnailName = null)
|
2016-09-04 21:59:32 +01:00
|
|
|
{
|
2016-09-08 23:22:29 +01:00
|
|
|
return $this->album->getAlbumSource()->getUrlToPhoto($this, $thumbnailName);
|
2016-09-04 21:59:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function url()
|
|
|
|
{
|
|
|
|
return route('viewPhoto', [
|
|
|
|
'albumUrlAlias' => $this->album->url_alias,
|
2016-09-06 19:47:25 +01:00
|
|
|
'photoFilename' => $this->storage_file_name
|
2016-09-04 21:59:32 +01:00
|
|
|
]);
|
|
|
|
}
|
2016-09-02 21:27:50 +01:00
|
|
|
}
|