jeudi 30 août 2018

Laravel Modal->save() it says Undefined property: stdClass::$plot

I am getting this Undefined property: stdClass::$plot error, and trying to fix that from last 2 days. Please help me, thanks in advance. NOTE: dd($video,$VodDetail,$tmdb ); all are set and have required details.

$article= new Article();
            $article->type = 'link';
            $article->title = $video->name;
            $article->description = ($VodDetail->plot)?$VodDetail->plot:($tmdb->overview)?$tmdb->overview:'';
            $article->releaseDate = ($VodDetail->releasedate)?Carbon::parse($VodDetail->releasedate)->format('Y'):($tmdb->release_date)?Carbon::parse($tmdb->release_date)->format('Y'):'';
            $article->stream_id = $video->stream_id;
            $article->trailer = ($VodDetail->youtube_trailer)?'https://www.youtube.com/embed/'.$VodDetail->youtube_trailer:null;
            $article->rating = ($video->rating)?$video->rating:($tmdb->vote_average)?$tmdb->vote_average:'';
            $article->director = ($VodDetail->director)?$VodDetail->director:null;
            $article->runtime = ($VodDetail->duration)?$VodDetail->duration:null;
            $article->avatar = ($img_path) ? url(url($img_path)) : 'default.jpg';
            $article->background_image = ($VodDetail->backdrop_path) ? (($VodDetail->backdrop_path[0])?$VodDetail->backdrop_path[0]:null) : null;
            $article->genre = ($VodDetail->genre) ? preg_replace("' / '", ",", $VodDetail->genre) : null;
            $article->category_idFk = Category::where('title', 'LIKE', $xtreamCategories[$video->category_id])->first()->category_id ?: null;
            $article->tmdb_id = ($VodDetail->tmdb_id)?$VodDetail->tmdb_id:($tmdb->id)?$tmdb->id:'';
            $article->created_at = Carbon::now()->toDateTimeString();
            $article->updated_at = Carbon::now()->toDateTimeString();
            $article->imdb_id = ($tmdb->imdb_id)?$tmdb->imdb_id:null;
            $article->secondary_title = ($tmdb->original_title)?$tmdb->original_title:null;
            $article->language_name = ($tmdb->spoken_languages)?$tmdb->spoken_languages[0]->name:null;
$article->save();

If I put dd($article); before $article-save(); it gives me following result:

Article {#4048
  #primaryKey: "article_id"
  #table: "articles"
  +timestamps: false
  #fillable: array:15 [
    0 => "subtitle_path"
    1 => "stream_id"
    2 => "type"
    3 => "imdb_id"
    4 => "runtime"
    5 => "title"
    6 => "releaseDate"
    7 => "description"
    8 => "avatar"
    9 => "rating"
    10 => "category_idFk"
    11 => "director"
    12 => "genre"
    13 => "created_at"
    14 => "updated_at"
  ]
  #attributes: array:19 [
    "type" => "link"
    "title" => "Sacudete Las Penas"
    "description" => "One of the prisoners who have to spend a long season in jail, González, ...."
    "releaseDate" => "2018"
    "stream_id" => 9415
    "trailer" => "https://www.youtube.com/embed/5jstm_JeyW8"
    "rating" => 10.0
    "director" => null
    "runtime" => "01:25:17"
    "avatar" => "default.jpg"
    "background_image" => null
    "genre" => "Drama"
    "category_idFk" => 1
    "tmdb_id" => 518326
    "created_at" => "2018-08-30 07:30:45"
    "updated_at" => "2018-08-30 07:30:45"
    "imdb_id" => "tt7945596"
    "secondary_title" => "Sacudete Las Penas"
    "language_name" => "Español"
  ]
  #guarded: array:1 [
    0 => "*"
  ]
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire