55use App \Http \Controllers \Controller ;
66use App \Models \Category ;
77use App \Models \Link ;
8+ use App \Models \Note ;
89use App \Models \Tag ;
910use Illuminate \Http \Request ;
1011
@@ -29,10 +30,15 @@ public function index()
2930 ->byUser (auth ()->id ())
3031 ->get ();
3132
33+ $ notes = Note::onlyTrashed ()
34+ ->byUser (auth ()->id ())
35+ ->get ();
36+
3237 return view ('actions.trash.index ' , [
3338 'links ' => $ links ,
3439 'categories ' => $ categories ,
3540 'tags ' => $ tags ,
41+ 'notes ' => $ notes ,
3642 ]);
3743 }
3844
@@ -63,6 +69,11 @@ public function clearTrash(Request $reques, $model)
6369 ->byUser (auth ()->id ())
6470 ->get ();
6571 break ;
72+ case 'notes ' :
73+ $ entries = Note::onlyTrashed ()
74+ ->byUser (auth ()->id ())
75+ ->get ();
76+ break ;
6677 }
6778
6879 if (empty ($ entries )) {
@@ -72,6 +83,7 @@ public function clearTrash(Request $reques, $model)
7283
7384 foreach ($ entries as $ entry ) {
7485 $ entry ->forceDelete ();
86+ $ entry ->flushCache ();
7587 }
7688
7789 alert (trans ('trash.delete_success. ' . $ model ), 'success ' );
@@ -101,6 +113,9 @@ public function restoreEntry(Request $request, $model, $id)
101113 case 'tag ' :
102114 $ entry = Tag::withTrashed ()->find ($ id );
103115 break ;
116+ case 'note ' :
117+ $ entry = Note::withTrashed ()->find ($ id );
118+ break ;
104119 }
105120
106121 if (empty ($ entry )) {
@@ -112,8 +127,9 @@ public function restoreEntry(Request $request, $model, $id)
112127 }
113128
114129 $ entry ->restore ();
130+ $ entry ->flushCache ();
115131
116- alert (trans ('trash.delete_success . ' . $ model ), 'success ' );
132+ alert (trans ('trash.delete_restore . ' . $ model ), 'success ' );
117133
118134 return redirect ()->route ('get-trash ' );
119135 }
0 commit comments