i'm habving truble showing uploaded images from data base.
this is what i'm getting :
[{"id":4,"model_type":"App\Asset","model_id":16,"collection_name":"photos","name":"5d83621e459eb_le15","file_name":"5d83621e459eb_le15.jpg","mime_type":"image/jpeg","disk":"public","size":40804,"manipulations":[],"custom_properties":{"generated_conversions":{"thumb":true}},"responsive_images":[],"order_column":4,"created_at":"2019-09-19 11:11:05","updated_at":"2019-09-19 11:11:06"}]
view.blade.php
<div class="panel-body">
<div>
<h2></h2>
<span class="label label-info label-many"> </span>
<div> </div>
<br>
<p></p>
<h5><strong></strong></h5>
<p> </p>
<span class="label label-success label-many"> : </span>
<span class="label label-default label-many"> : {!! $asset->budget !!}</span>
<span class="label label-warning label-many"> : {!! $asset->nbAssociers !!}</span>
<br>
<br>
<strong> : </strong>
<p></p>
<br>
<a style="margin-top:20px;" class="btn btn-default" href="">
</a>
</div>
</div>
Model
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\Models\Media;
use Laravel\Scout\Searchable;
class Asset extends Model implements HasMedia
{
use SoftDeletes, HasMediaTrait;
use Searchable;
public $table = 'assets';
protected $appends = [
'photos',
];
protected $dates = [
'created_at',
'updated_at',
'deleted_at',
];
protected $fillable = [
'name',
'description',
'status_id',
'created_at',
'updated_at',
'deleted_at',
'category_id',
'location_id',
'date',
'budget',
'nbAssociers',
'assigned_to_id',
];
public static function boot()
{
parent::boot();
Asset::observe(new \App\Observers\AssetsHistoryObserver);
}
public function registerMediaConversions(Media $media = null)
{
$this->addMediaConversion('thumb')->width(50)->height(50);
}
public function assetsHistories()
{
return $this->hasMany(AssetsHistory::class, 'asset_id', 'id');
}
public function category()
{
return $this->belongsTo(AssetCategory::class, 'category_id');
}
public function getphotosAttribute()
{
return $this->getMedia('photos');
}
public function status()
{
return $this->belongsTo(AssetStatus::class, 'status_id');
}
public function location()
{
return $this->belongsTo(AssetLocation::class, 'location_id');
}
public function assigned_to()
{
return $this->belongsTo(User::class, 'assigned_to_id');
}
and i'm using in my controller
use MediaUploadingTrait;
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire