“Laravel -Update -Methode” Code-Antworten

Laravel -Update aus der Abfrage

$affected = DB::table('users')
              ->where('id', 1)
              ->update(['votes' => 1]);
Alberto Peripolli

Laravel -Update wo

User::where('id', $user_id)
    ->update([
           'name' => $name
    ]);
Snippets

Laravel -Update -Modell aus der Anfrage

public function update(Request $request, Teacher $teacher)
{
    $teachers = $request->all();
    $teacher->save();
    return back()->with('message', 'Record Successfully Updated!');
}
Shadow

Laravel -Update

Flight::where('active', 1)
      ->where('destination', 'San Diego')
      ->update(['delayed' => 1]);
Cooperative Crab

Laravel -Update -Modell aus der Anfrage

public function update(Request $request, Teacher $teacher)
{
    $input = $request->all();
    $teacher->fill($input)->save();
    return back()->with('message', 'Record Successfully Updated!');
}
Shadow

Laravel -Update -Methode

 public function update(UpdatePostRequest $request, Post $post)
    {
        $request->validate([
        //unique:table,column,id
        "title" => "required|unique:posts,title,".$this->route('post')->id."|min:5",
        "description" => "required|min:15",
        "cover" => "nullable|file|mimes:jpeg,png|max:5000"
        ]);

        $post->title = $request->title;
        $post->slug = Str::slug($request->title);
        $post->description = $request->description;
        $post->excerpt = Str::words($request->description,50);

        if($request->hasFile('cover')){

//            delete old cover
            Storage::delete("public/cover/".$post->cover);

//            upload new cover
            $newName = "cover_".uniqid()."_".$request->file('cover')->extension();
            $request->file('cover')->storeAs("public/cover",$newName);

//            save to table
                $post->cover = $newName;
        }

            $post->update();

        return redirect()->route('post.detail',$post->slug)->with('status','Post Updated');
    }
WinMaw

Ähnliche Antworten wie “Laravel -Update -Methode”

Fragen ähnlich wie “Laravel -Update -Methode”

Weitere verwandte Antworten zu “Laravel -Update -Methode” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen