<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Note;
use App\User;
use Auth;

class NoteController extends Controller
{
    public function add_note(Request $req)
    {
        $note = $req->note;
        $date_time = $req->date_time;

        $sav = new Note;
        $sav->note = $note;
        $sav->user_id = Auth::user()->id;
        $sav->time = $date_time;
        $sav->save();

        return redirect()->back();
    }

    public function change_note_status($id){

    	$ch = Note::find($id);
    		if($ch->status == 1){
    			$ch->status = 0;
    		}
    		else{
    			$ch->status = 1;
    		}
    	$ch->save();

    	return redirect()->back();
    }

    public function remove_note($id){

    	$del = Note::find($id)->delete();

    	return redirect()->back();
    }
}
