Exemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(AdmissionRequest $request, Admission $admission)
 {
     $record = array_except($request->all(), array('fileName'));
     if ($request->get('image') != $admission->image) {
         if (!preg_match('/^img/', $admission->image)) {
             unlink($admission->image);
         }
         $filename = $request->get("fileName");
         $src = 'fileStorage/temp/' . $filename;
         $des = 'fileStorage/persons/' . $request->get('name') . '.jpg';
         rename($src, $des);
         $record['image'] = $des;
     }
     $admission->update($record);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(AdmissionRequest $request)
 {
     $input = $request->all();
     $input['photo'] = 'fileStorage/' . $_FILES['photo']['name'];
     move_uploaded_file($_FILES['photo']['tmp_name'], $input['photo']);
     $admission = Admission::create($input);
     $info['exam'] = $input['exam'];
     $info['board'] = $input['board'];
     $info['roll'] = $input['roll'];
     $info['year'] = $input['year'];
     $info['gpa'] = $input['gpa'];
     $info['admission_id'] = $admission->id;
     Academicinfotemp::create($info);
     return "Saved!";
 }