1

i want to delete row permanently from database via delete button.

this is my button code in a form that sends id to destroy function.

{!! Form::open(array('url' => 'admin/newsmaster/'.$value->id, 'class' => 'form-horizontal create_form', 'files' => true)) !!}
    <input type="hidden" name="_method" value="delete">
    <button type="submit" class="btn red">Delete</button>
</form>

this is my destroy function:

public function destroy($id)
    {
        $feed= Feed::find($id);
        $feed->delete();
        Session::flash('message', 'News Deleted Successfully.');
        $redirect = 'admin/newsmaster';
        return Redirect::to($redirect);
    }

this is my Feed model:

protected $table = 'feed_news';
use SoftDeletes;
protected $softDelete = true;
protected $dates = ['deleted_at'];

my problem is when i click on delete option my row in database doesn't get deleted, instead it updates the deleted_at column.

1
  • 1
    Because you are using SoftDeletes Commented Feb 19, 2018 at 9:07

2 Answers 2

2

To permanently remove a soft deleted model from the database, use the forceDelete method:

$feed= Feed::find($id);
$feed->forceDelete();

Documentation

Sign up to request clarification or add additional context in comments.

Comments

0

You are using Eloquent's Soft Delete Trait. Therefore, you specified in your FeedModel to soft delete the records. By removing its from the model, Eloquent will permanently delete the specific row.

FeedModel

protected $table = 'feed_news';

protected $dates = ['deleted_at'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.