Я хочу получить результаты для всех записей, но могу получить результат только для одной записи в Laravel 5.6 - PullRequest
0 голосов
/ 14 апреля 2020

Я получаю ошибку при сравнении event_id для всех записей из базы данных. Это работает для отдельной записи, но я хочу получить cast_crew из всех записей. Проверьте ниже на ошибку, выданную почтальоном. Пожалуйста, помогите мне.

  $input = json_decode(file_get_contents('php://input', true));

    $city = $input->city;

    $venue = Venue::where('venue_city', $city)
    ->get()->first();

    //Banner
    $eventPromotionalMedia = EventPromotionalMedia::where('event_promotional_media_is_advertisement', 1)
    ->select('event_promotional_media_url')
    ->get();

    //Nearby Events
    //

    //Events
    $events = Event::where('event.event_type', 1)
    ->join('event_category', 'event.event_category_id', '=', 'event_category.event_category_id')
    ->join('event_promotional_media', 'event_promotional_media.event_promotional_media_event_id', '=', 'event.event_id')
    'event_cast_map.event_cast_map_cast_crew_id')
    ->select('event.event_id', 'event.event_title', 'event_category.event_category_name','event_promotional_media_url', 'event.event_short_description', 'event.event_description', 'event.event_language', 'event.event_duration')//, 'cast_crew_full_name', 'cast_crew_designation', 'cast_crew_dp_url')
    ->get();

    //Plays
    $event = Event::where('event.event_type', 2)
    ->join('event_category', 'event.event_category_id', '=', 'event_category.event_category_id')
    ->join('event_promotional_media', 'event_promotional_media.event_promotional_media_event_id', '=', 'event.event_id')
   'event_cast_map.event_cast_map_cast_crew_id')
    ->select('event_id', 'event.event_title', 'event_category.event_category_name','event_promotional_media_url', 'event.event_short_description', 'event.event_description', 'event.event_language', 'event.event_duration')//, 'cast_crew_full_name', 'cast_crew_designation', 'cast_crew_dp_url')
    ->get();

    $event_cast_map_cast = EventCastMap::where('event_cast_map_event_id', $event->event_id)
    ->where('cast_crew_type', 'C')
    ->join('cast_crew', 'cast_crew_id', '=', 'event_cast_map_cast_crew_id')
    ->select('cast_crew.cast_crew_full_name', 'cast_crew.cast_crew_dp_url', 'cast_crew.cast_crew_designation')
    ->get();

    $event_cast_map_crew = EventCastMap::where('event_cast_map_event_id', $event->event_id)
    ->where('cast_crew_type', 'R')
    ->join('cast_crew', 'cast_crew_id', '=', 'event_cast_map_cast_crew_id')
    ->select('cast_crew.cast_crew_full_name', 'cast_crew.cast_crew_dp_url', 'cast_crew.cast_crew_designation')
    ->get();

    $event_cast_maps_cast = EventCastMap::where('event_cast_map_event_id', $events->event_id)
    ->where('cast_crew_type', 'C')
    ->join('cast_crew', 'cast_crew_id', '=', 'event_cast_map_cast_crew_id')
    ->select('cast_crew.cast_crew_full_name', 'cast_crew.cast_crew_dp_url', 'cast_crew.cast_crew_designation')
    ->get();

    $event_cast_maps_cast_crew = EventCastMap::where('event_cast_map_event_id', $events->event_id)
    ->where('cast_crew_type', 'R')
    ->join('cast_crew', 'cast_crew_id', '=', 'event_cast_map_cast_crew_id')
    ->select('cast_crew.cast_crew_full_name', 'cast_crew.cast_crew_dp_url', 'cast_crew.cast_crew_designation')
    ->get();

    $result1 = json_decode(json_encode(['bannerImages'=>$eventPromotionalMedia]), true);
    $result2 = json_decode(json_encode(['events'=>$events]), true);
    $result3 = json_decode(json_encode(['plays'=>$event]), true);
    $result4 = json_decode(json_encode(['plays_cast'=>$event_cast_map_cast]), true);
    $result5 = json_decode(json_encode(['plays_crew'=>$event_cast_map_crew]), true);
    $result6 = json_decode(json_encode(['events_casts'=>$event_cast_maps_cast]), true);
    $result7 = json_decode(json_encode(['events_crew'=>$event_cast_maps_cast_crew]), true);
    $result8 = array_merge($result3,$result4,$result5);
    $result9 = array_merge($result2,$result6,$result7);
    $result = array_merge($result1,$result8,$result9);
    return $result;

Ошибка: исключение: свойство [event_id] не существует в этом экземпляре коллекции. в файле C: \ xampp \ htdocs \ ticketweb \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Traits \ EnumeratesValues. php в строке 821

0 C: \ xampp \ htdocs \ ticketweb \ app \ Http \ Controllers \ ApiController. php (68): Подсветка \ Поддержка \ Коллекция -> __ get ('event_id')

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...