Learner\Repositories\VideoRepositoryInterface::hasChanged PHP Method

hasChanged() public method

Check the video resource changed.
public hasChanged ( integer $id, string $resource_type, string $resource_id ) : boolean
$id integer
$resource_type string
$resource_id string
return boolean
    public function hasChanged($id, $resource_type, $resource_id);

Usage Example

 /**
  * 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]);
 }