public function store() { //checks if the user is authorised to add school if (\Auth::check()) { $newschoolname = Request::get('schoolname'); // calls the school name from the school view file $newschoolurl = Request::get('schoolURL'); // calls the school url from the school view file school::insert(['school_name' => $newschoolname, 'school_url' => $newschoolurl]); //inserts the new data into a new tuple $message = "School Added: Success"; // indicates success to the user } else { $message = "School Added: Failed"; } // indicates failure to the user $schooltable = school::all(); //calls the schools from the model school. all() selects all, included the new entry //Tells user if logged in or not. necessary for the view if (\Auth::check()) { $name = \Auth::user()->name; } else { $name = "Guest"; } //returns the school view, and passes the schooltable, the message, and user name to the view return view('school', compact('schooltable', 'message', 'name')); }
public function delete($filenumber, $name) { //checks if user is authorised if (\Auth::check()) { //checks if user posted the content if (\Auth::user()->name == $name) { //finds the tuple and deletes it content::where('filenumber', '=', $filenumber)->delete(); //deletes the records with file number from raters raters::where('filenumber', '=', $filenumber)->delete(); $message = "Delete Successful"; //tells user delete was successful } } else { $message = "Delete failure"; } //tells user if delete was a failure //tells user if logged in or not if (\Auth::check()) { $name = \Auth::user()->name; } else { $name = "Guest"; } //gets the school table $schooltable = school::all(); //redirects to school so that user can see message return view('school', compact('schooltable'), compact('message', 'name')); }