Não está aparecendo a imagem. A imagem fica salva na pasta. E a pasta de imagem está no public/storage/series_cover.
App\Repositories\EloquentSeriesRepository
public function add(SeriesFormRequest $request): Series
{
return DB::transaction(function () use ($request) {
$serie = Series::create([
'nome' => $request->nome,
'cover' => $request->coverPath,
]);
$seasons = [];
for ($i = 1; $i <= $request->seasonsQty; $i++) {
$seasons[] = [
'series_id' => $serie->id,
'number' => $i,
];
}
App\Http\Requests\SeriesFormRequest
interface SeriesRepository
{
public function add(SeriesFormRequest $request): Series;
}
App\Models\Series
class Series extends Model
{
use HasFactory;
protected $fillable = ['nome', 'cover'];
App\Http\Controllers\SeriesController
public function store(SeriesFormRequest $request)
{
$coverPath = $request->file('cover')
->store('series_cover', 'public');
$request->coverPath = $coverPath;
$serie = $this->repository->add($request);
\App\Events\SeriesCreated::dispatch(
$serie->nome,
$serie->id,
$request->seasonsQty,
$request->episodesPerSeason,
);
App\resources\views\season\index.blade.php
<x-layout title="Temporadas de {!! $series->nome !!}">
<div class="d-flex justify-center">
<img src="{{ asset('storage/' . $series->cover) }}"
style="height:400px"
alt="Capa da série"
class="img-fluid">
</div>
<ul class="list-group">
@foreach ($seasons as $season)
<li class="list-group-item d-flex justify-content-between align-items-center">
<a href="{{ route('episodes.index', $season->id) }}">
Temporada {{ $season->number }}
</a>
<span class="badge bg-secondary">
{{ $season->numberOfWatchedEpisodes() }} / {{ $season->episodes->count() }}
</span>
</li>
@endforeach
</ul>
</x-layout>
App\resources\views\series\index.blade.php
<x-layout title="Séries" :mensagem-sucesso="$mensagemSucesso">
@auth
<a href="{{ route('series.create') }}" class="btn btn-dark mb-2">Adicionar</a>
@endauth
<ul class="list-group">
@foreach ($series as $serie)
<li class="list-group-item d-flex justify-content-between align-items-center">
<div class="d-flex align-items-center">
<img src="{{ asset('storage/' . $serie->cover) }}" width="100" class="img-thumbnail me-3" alt="">
@auth <a href="{{ route('seasons.index', $serie->id) }}"> @endauth
{{ $serie->nome }}
@auth </a> @endauth
</div>
@auth
<span class="d-flex">
<a href="{{ route('series.edit', $serie->id) }}" class="btn btn-primary btn-sm">
E
</a>
<form action="{{ route('series.destroy', $serie->id) }}" method="post" class="ms-2">
@csrf
@method('DELETE')
<button class="btn btn-danger btn-sm">
X
</button>
</form>
</span>
@endauth
</li>
@endforeach
</ul>
</x-layout>