public function main()
 {
     $codes = user_code::all();
     return view('all_codes', compact('codes'));
     //else
     //  return redirect ('login');
 }
 public function formdata()
 {
     if (Request::ajax()) {
         $type = Request::get('type');
         if ($type == 'run_it') {
             $data = Request::get('code');
             $myfile = fopen("code.php", "w+") or die("Unable to open file!");
             fwrite($myfile, '<?php ' . $data . ' ?>');
             fclose($myfile);
             //  print_r($data);
         } elseif ($type === 'store_it') {
             $code = Request::get('code');
             $pub = Carbon::now();
             $test = new user_code();
             $test->code = $code;
             $test->published_at = $pub;
             $test->save();
             //print_r($code);
         }
     }
     //ajax if closes here
 }
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     if (\Auth::user()) {
         $role = \Auth::user()->role;
         if ($role == 'user') {
             return view('interpreter_gui');
         } else {
             $codes = user_code::all();
             return view('all_codes', compact('codes'));
             //return view('all_codes');
         }
     } else {
         return redirect('/login');
     }
 }