Beispiel #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(TeacherRequest $request, Teacher $teacher)
 {
     $record = array_except($request->all(), array('fileName'));
     if ($request->get('image') != $teacher->image) {
         if (!preg_match('/^img/', $teacher->image)) {
             unlink($teacher->image);
         }
         $filename = $request->get("fileName");
         $src = 'fileStorage/temp/' . $filename;
         $des = 'fileStorage/persons/' . $request->get('name') . '.jpg';
         rename($src, $des);
         $record['image'] = $des;
     }
     $teacher->update($record);
 }