Answers for "delete laravel query"

PHP
10

laravel update from query

$affected = DB::table('users')
              ->where('id', 1)
              ->update(['votes' => 1]);
Posted by: Guest on May-07-2020
2

laravel eloquent remove from db

$res=User::where('id',$id)->delete();
Posted by: Guest on November-05-2020
1

delete route method in laravel

<form method="POST" action="{{ route('route.name', [ 'id'=> $item->id ]) }}">
              @csrf
              <input type="hidden" name="_method" value="DELETE">
              <button type="submit" class="btn btn-danger btn-icon">
                <i data-feather="delete"></i>
              </button>
            </form>
Posted by: Guest on October-18-2020
2

get all data eloquent laravel

Blog::all();

//example usage.
$posts = Blog::all();
Posted by: Guest on October-28-2020
1

laravel query with trashed

$user->roles()->withTrashed()->get();
Posted by: Guest on June-19-2020
2

laravel delete relationship data

class User extends Eloquent
{
    public function photos()
    {
        return $this->has_many('Photo');
    }

    // this is a recommended way to declare event handlers
    public static function boot() {
        parent::boot();

        static::deleting(function($user) { // before delete() method call this
             $user->photos()->delete();
             // do the rest of the cleanup...
        });
    }
}
Posted by: Guest on November-08-2020

Browse Popular Code Answers by Language