1
resposta

[Projeto] como fiz o EpisodesController

<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Season;
use App\Models\Episode;
use App\Models\Series;

class EpisodesController extends Controller
{
    public function index(Series $series)
    {
        
        $episodes = $series->episodes()->with('season')->get();

        return response()->json($episodes);
    }

    public function update(Request $request, Episode $episode)
    {
        $id = $episode->id;
        $episode = Episode::find($id);
        $episode->watched = $request->input('watched', true);
        $episode->save();

        return response()->json($episode);
    }
}
1 resposta

Muito bom.