app/Http/Controllers/ComicController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Comic $comic)
    {
         $request->validate([
            "title" => "required|string|max:150|unique:comics,title,{$comic->id}",
            "description" => "required|string",
            "thumb" => "required|url",
            "price" => "required|numeric|between:0,99999.99",
            "series" => "required|string|max:50",
            "sale_date" => "required|date",
            "type" => "required|string|max:20"
        ]);
        $data = $request->all();
        $comic->title = $data["title"];
        $comic->description = $data["description"];
        $comic->thumb = $data["thumb"];
        $comic->price = $data["price"];
        $comic->series = $data["series"];
        $comic->sale_date = $data["sale_date"];
        $comic->type = $data["type"];
        $comic->save();
        return redirect()->route('comics.show', $comic->id);
    }
public function update ( Request $ request , Comic $ comic ) { $ request -> validate ( [ " title " => " required|string|max:150|unique:comics,title, { $ comic -> id } " , " description " => " required|string " , " thumb " => " required|url " , " price " => " required|numeric|between:0,99999.99 " , " series " => " required|string|max:50 " , " sale_date " => " required|date " , " type " => " required|string|max:20 " ] ) ; $ data = $ request -> all ( ) ; $ comic -> title = $ data [ " title " ] ; $ comic -> description = $ data [ " description " ] ; $ comic -> thumb = $ data [ " thumb " ] ; $ comic -> price = $ data [ " price " ] ; $ comic -> series = $ data [ " series " ] ; $ comic -> sale_date = $ data [ " sale_date " ] ; $ comic -> type = $ data [ " type " ] ; $ comic -> save ( ) ; return redirect ( ) -> route ( 'comics.show' , $ comic -> id ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//Validazione