Modif url
This commit is contained in:
@@ -5,9 +5,9 @@ namespace Meoran\Images\Model;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\Image as InterventionImage;
|
||||
use Meoran\Images\Exception\InvalidContent;
|
||||
use Spatie\ImageOptimizer\OptimizerChain;
|
||||
use \Intervention\Image\Image as InterventionImage;
|
||||
|
||||
/**
|
||||
* Class Image
|
||||
@@ -34,7 +34,11 @@ class Image extends Model
|
||||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return app('url')->to('/' . config('image.route') . '/original/' . $this->filename);
|
||||
$route = config('image.route');
|
||||
if (empty($route)) {
|
||||
return null;
|
||||
}
|
||||
return app('url')->to('/' . $route . '/' . $this->filename);
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
@@ -101,7 +105,8 @@ class Image extends Model
|
||||
$this->attributes['filename'] = $value;
|
||||
}
|
||||
|
||||
public function fileExist() {
|
||||
public function fileExist()
|
||||
{
|
||||
return is_file($this->getPath());
|
||||
}
|
||||
|
||||
@@ -168,7 +173,8 @@ class Image extends Model
|
||||
* @param $relationName
|
||||
* @return MorphToMany
|
||||
*/
|
||||
public static function createRelation(Model $class, $relationName) {
|
||||
public static function createRelation(Model $class, $relationName)
|
||||
{
|
||||
|
||||
$instance = $class->newRelatedInstance(self::class);
|
||||
|
||||
@@ -180,7 +186,7 @@ class Image extends Model
|
||||
|
||||
$relation = new MorphToMany(
|
||||
$instance->newQuery(), $class, $name, $table,
|
||||
$foreignKey, $relatedKey, $relationName , $inverse
|
||||
$foreignKey, $relatedKey, $relationName, $inverse
|
||||
);
|
||||
$relation->withPivot('position');
|
||||
|
||||
|
Reference in New Issue
Block a user