コード例 #1
0
 /**
  * Store a newly created File in the DB
  *
  * @return Response 200
  * @return string message
  */
 public function store(Request $request)
 {
     $file = new UserFile();
     $uploaded_file = $request->file('file');
     $file_content = File::get($uploaded_file->path());
     //Create File
     $file->fileType = $uploaded_file->getClientOriginalExtension();
     $file->createdBy = Auth::id();
     $file->fileContent = $file_content;
     $file->save();
     return Response::json(array('error' => False, 'message' => 'File Successfully Stored'), 201);
 }
コード例 #2
0
 /**
  * Display a listing of all Comments for particular File.
  *
  * @return Response 200
  * @return jsonObject 'comments'
  */
 public function index($file_id)
 {
     $input = Input::all();
     $user_file = UserFile::find($file_id);
     $comments = $user_file->returnCommentsV1();
     return Response::json(array('comments' => $comments), 200);
 }
コード例 #3
0
 /**
  * Store a newly created File in the DB
  *
  * @return Response 200
  * @return string message
  */
 public function store(Request $request)
 {
     $input = Input::all();
     $file = new UserFile();
     $uploaded_file = $request->file('file');
     $file_content = File::get($uploaded_file->path());
     //Create File
     $file->fileType = $uploaded_file->getClientOriginalExtension();
     $file->createdBy = Auth::id();
     $file->fileContent = $file_content;
     $file->save();
     $groups_files = new GroupFile();
     $groups_files->file_id = $file->id;
     $groups_files->group_id = $input['groupId'];
     $groups_files->assignment_id = $input['assignmentId'];
     $groups_files->save();
     return Redirect::to('/comments');
 }
コード例 #4
0
 public function handle($request, Closure $next)
 {
     $input = Input::all();
     $route = Route::getRoutes()->match($request);
     //Validate
     $validator = Validator::make(Input::all(), Comment::$storageRulesV1);
     if (!$validator->passes()) {
         return Response::json(array('error' => True, 'messages' => $validator->messages()), 400);
     }
     //Make Sure File Exists
     $file_id = $route->parameter('files');
     $file = UserFile::find($file_id);
     if (empty($file)) {
         return Response::json(array('error' => True, 'message' => 'File Does Not Exist'), 400);
     }
     return $next($request);
 }
コード例 #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $v = Validator::make(Request::all(), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput();
     } else {
         $user = new User();
         $user->name = Request::get('name');
         $user->email = Request::get('email');
         $user->type = Request::get('type');
         $user->password = bcrypt(Request::get('password'));
         $user->save();
         $gInfo = new Generalinfo();
         $gInfo->user_id = $user->id;
         $gInfo->save();
         $pInfo = new Professionalinfo();
         $pInfo->user_id = $user->id;
         $pInfo->save();
         $data['email'] = Request::get('email');
         $data['name'] = Request::get('name');
         // Mail::send('emails.welcome', $data, function($message) use ($data)
         //           {
         //               $message->from('*****@*****.**', "Wavexpo");
         //               $message->subject("Welcome to Wavexpo Please visit our website to continu you information");
         //               $message->to($data['email']);
         //           });
         //return redirect()->action('UserFilesController@store', [$user->id,]);
         // File Storage
         $file = new File();
         $file->name = Request::get('filename');
         $file->desc = Request::get('desc');
         $file->type = Request::get('filetype');
         if (Request::hasFile('file')) {
             $destination = 'files/';
             $filename = str_random(6) . "_" . Request::file('file')->getClientOriginalName();
             Request::file('file')->move($destination, $filename);
             $file->file = $filename;
         } else {
             $file->file = Request::get('file');
         }
         $file->save();
         $userfile = new UserFile();
         $userfile->user_id = $user->id;
         $userfile->file_id = $file->id;
         $userfile->save();
         return redirect('users');
     }
 }