ソースを参照

添加提示语

durong 5 年 前
コミット
e98b82156f
共有1 個のファイルを変更した3 個の追加3 個の削除を含む
  1. 3 3
      app/Repositories/MusicRepository.php

+ 3 - 3
app/Repositories/MusicRepository.php

@@ -172,11 +172,11 @@ class MusicRepository
     {
         $post_music_rel = $this->postMusicCategoryRel->select('mid')->where('id', $request['id'])->first();
         $post_music = $this->postMusic->where('id',$post_music_rel->mid)->first();
-        if($post_music == null) {
-            $post_music = new PostMusic();
-            $post_music->name = $request['name'];
+        if (!$post_music) {
+            throw new HttpException(500, '没有找到对应的音乐');
         }
         $date = date('Y-m-d H:i:s');
+        $post_music->name = $request['name'];
         $post_music->url = $request['url'];
         $post_music->music_duration = $request['music_duration'];
         $post_music->updated_at = $date;