Actually the query which I said was working wasn't my mistake, I am going to change it and hopefully should work.
Query is not working even though I have one almost identical working.
I am trying to build a communication page where emails can be filtered etc...
I created the page and emails can be successfully filtered however, I wanted users to be able to save shortcuts to save them time filtering the same again and again. So I decided to create a comm shortcut object which stored each value of the filter and stores the array as a string by serialising it.
My last task is to execute the shortcut and filter through the emails so I am using pretty much the same query as the without shortcut one but there seems to be a problem that I am not sure about please help.
Exception
(1/1) BadMethodCallException Call to undefined method Illuminate\Database\Query\Builder::travellers() in Builder.php (line 2445)Query which is working
$travellerEmails = Traveller::where('gtcTraveler_Email', '!=', null)
->when($request->has('academicYears'), function ($query) use ($request)
{
$query->whereHas('travellers', function ($query) use ($request)
{
$query->whereHas('passes', function ($query) use ($request)
{
$query->whereHas('academicYear', function ($query) use ($request)
{
$query->whereIn('gtcPasses_gtcAcademicYears_ID', $request->input('academicYears'));
});
});
});
})->pluck('gtcTraveler_Email');
Variables
$shortcut = CommunicationShortcut::where('id', $request->input('shortcut'))->firstOrFail();
$areas = unserialize($shortcut->areas);
Query not working
$travellerEmails = Traveller::where('gtcTraveler_Email', '!=', null)
->when($academicYears, function ($query) use ($academicYears)
{
$query->whereHas('travellers', function ($query) use ($academicYears)
{
$query->whereHas('passes', function ($query) use ($academicYears)
{
$query->whereHas('academicYear', function ($query) use ($academicYears)
{
$query->whereIn('gtcPasses_gtcAcademicYears_ID', $academicYears);
});
});
});
})->pluck('gtcTraveler_Email');
please help, I am just confused why its not working? Thanks in advance.
Please or to participate in this conversation.