Schema::table('flights', function (Blueprint $table) {
$table->softDeletes();
});
$flight->restore();
$table->softDeletes();
$flight->forceDelete();
$model = Contents::find( $id );
$model->delete();
use AppModelsFlight;
$flights = Flight::withTrashed()
->where('account_id', 1)
->get();
use IlluminateDatabaseEloquentModel;
use IlluminateDatabaseEloquentSoftDeletes;
class Post extends Model {
use SoftDeletes;
protected $table = 'posts';
// ...
}
Namespace: use IlluminateDatabaseEloquentSoftDeletes; ->in modal
Invoking : use SoftDeletes; -> in modal
php artisan make:migration add_deleted_at_to_contacts_table
Creating a softdelete column : $table->softDeletes(); -> add_deleted_at_to_contacts_table.php
Other Important function
withTashed()->delete or nonDelete(for restore method and forcDelete method)
onlyTrashed()->delete(for view)
restore()
forceDelete()
$flights = Flight::where('active', 1)
->orderBy('name')
->take(10)
->get();