Learner\Repositories\VideoRepositoryInterface::update PHP Method

update() public method

Update video.
public update ( integer $id, array $data ) : array
$id integer
$data array
return array
    public function update($id, array $data);

Usage Example

Exemplo n.º 1
0
 /**
  * Update a video.
  *
  * /admin/videos/{id} put
  *
  * @param  integer $id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function update($id)
 {
     $form = $this->videos->getSaveForm();
     if (!$form->isValid()) {
         return $this->responseJson(['errors' => $form->getErrors()], 400);
     }
     $data = $form->getInputData();
     // if resource_type and resource_id not change, then not request api.
     if ($this->videos->hasChanged($id, $data['resource_type'], $data['resource_id'])) {
         $resourceInfo = $this->getResourceInfo($data['resource_type'], $data['resource_id']);
         $data['image'] = $resourceInfo['thumbnail_url'];
         $data['duration'] = $resourceInfo['duration'];
     }
     $video = $this->videos->update($id, $data);
     return $this->responseJson(['message' => '成功修改视频', 'video' => $video]);
 }