UserController1.php 1.0 KB

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