How do i permanently delete a soft deleted item?
My code does not work:)
public function destroy($id)
{
$obj = Upload::destroy($id);
}
in this case what is $flight variable? is it object of my Model?
Here is from documentation
$flight = App\Flight::find($id);
$flight-> forceDelete();
My model name is : "Upload" and i'm trying to permanent delete using the following way:
public function destroy($id)
{
$myItem = Upload::find($id);
$myItem->forceDelete();
}
But through an error which is :
FatalThrowableError in UploadController.php line 119:
Call to a member function forceDelete() on null
Do you get any result from this
$myItem = Upload::find($id);
dd($myItem);
Thank you very much ! It's working by the following way:
public function destroy($id)
{
$flight = Upload::where('id', $id)->forcedelete();
}
[Update] For some people who still are struggling today.
You need to get the $flight item this way:
$flight = Upload::withTrashed()->find($id);
and then force Delete
$flight->forceDelete();
If you get the flight this way: $flight = Upload::findOrFail($id);
it will always return null as the item has been soft deleted.
Please or to participate in this conversation.