how to delete in laravel 8 code example
Example 1: laravel soft delete
public function up()
{
Schema::table('users', function(Blueprint $table)
{
$table->softDeletes();
});
}
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Model {
use SoftDeletes;
protected $dates = ['deleted_at'];
}
Example 2: Laravel Delete
Flight::destroy(1);
Flight::destroy(1, 2, 3);
Flight::destroy([1, 2, 3]);
Flight::destroy(collect([1, 2, 3]));
Example 3: laravel delete
DB::table('users')->where('votes', '>', 100)->delete();