NoteController.php 888 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Http\Controllers\admin;
  3. use Illuminate\Http\Request;
  4. use App\Http\Requests;
  5. use App\Http\Controllers\Controller;
  6. use App\Models\Note;
  7. use App\User;
  8. use Auth;
  9. class NoteController extends Controller
  10. {
  11. public function add_note(Request $req)
  12. {
  13. $note = $req->note;
  14. $date_time = $req->date_time;
  15. $sav = new Note;
  16. $sav->note = $note;
  17. $sav->user_id = Auth::user()->id;
  18. $sav->time = $date_time;
  19. $sav->save();
  20. return redirect()->back();
  21. }
  22. public function change_note_status($id){
  23. $ch = Note::find($id);
  24. if($ch->status == 1){
  25. $ch->status = 0;
  26. }
  27. else{
  28. $ch->status = 1;
  29. }
  30. $ch->save();
  31. return redirect()->back();
  32. }
  33. public function remove_note($id){
  34. $del = Note::find($id)->delete();
  35. return redirect()->back();
  36. }
  37. }