2014-08-29 24 views
9

निम्नलिखित नरम हटाना कोड मेरे लिए ठीक काम करता है:Laravel शीतल हटाएँ बहाल() त्रुटि

$post = Post::find($post_id); 
$post->delete(); 

deleted_at क्षेत्र अद्यतन किया जाता है। लेकिन यह मेरे एक त्रुटि देता है:

$post = Post::find($post_id); 
$post->restore(); 

यहाँ त्रुटि है:

exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to a member function restore() on a non-object' 

मैं स्टंप्डया हूँ। Google अब तक कोई मदद नहीं है।

उत्तर

20

त्रुटि का कहना है $post एक गैर वस्तु है, Laravel बिना withTrashed()

Post::withTrashed()->find($post_id)->restore(); 

Laravel Docs - Soft Deleting

When querying a model that uses soft deletes, the "deleted" models will not be included...

+0

वर्क्स एक आकर्षण की तरह ट्रैश किए गए अभिलेख वापस नहीं करता है। धन्यवाद। – moreirapontocom

संबंधित मुद्दे