[TriLUG] Fighting a Laravel error. Help?
William Sutton via TriLUG
trilug at trilug.org
Wed Jan 25 13:25:23 EST 2023
relatedly (and I'm a Perl guy, not a Laravel guy so this is a shot in the
dark), can you explicitly cast the person id to an int before the equality
comparison?
William Sutton
On Wed, 25 Jan 2023, Scott Lambdin via TriLUG wrote:
> My instinct is to replace the comparison terms one at a time with a literal
> int and see what happens.
>
> On Tue, Jan 24, 2023, 6:51 PM Brian McCullough via TriLUG <trilug at trilug.org>
> wrote:
>
>> I have been running in circles for far too long and finally got well
>> past the point where I should have shouted for help.
>>
>>
>> I am getting an error from Laravel and I can't seem to see what to do to
>> fix it. I'm sure that it is something obvious and that I am just
>> blind.
>>
>>
>>
>> The error is "Object of class Collection could not be converted to int."
>>
>> This error occurs down near the bottom of the code below, the IF with
>> "$personData->person_type_id". All of my debugging dumps say that the
>> value is actually an INT.
>>
>>
>> =====================================================================
>>
>>
>> $peopleData = DB::connection('mysql_ems')
>> ->table('people')
>> ->whereNull('archived_at' )
>> ->select( 'id', 'first_name', 'last_name', 'person_type_id',
>> 'archived_at' )
>> ->get()
>> ->toArray();
>>
>> foreach ($peopleData as $personData) {
>>
>> echo "\nPersonType: " .
>> var_export($personData->person_type_id, true) . "\nPerson: " .
>> var_export($personData, true) . "\n\n";
>>
>> echo "PersonType: " . print_r(
>> $personData->person_type_id, true ) . "\n\n" ;
>>
>> if ($personData->person_type_id == $emsStudentType) {
>> $peopleStudents[] = [
>> 'ems' => $personData->id,
>> 'first' => $personData->first_name,
>> 'last' => $personData->last_name,
>> 'archived_at' => $personData->archived_at,
>> 'tms' => $personID->id
>> ];
>> }
>> }
>> }
>>
>>
>> =======================================================================
>>
>>
>> --
>> This message was sent to: Scott Lambdin <lopaki at gmail.com>
>> To unsubscribe, send a blank message to trilug-leave at trilug.org from that
>> address.
>> TriLUG mailing list : https://www.trilug.org/mailman/listinfo/trilug
>> Unsubscribe or edit options on the web :
>> https://www.trilug.org/mailman/options/trilug/lopaki%40gmail.com
>> Welcome to TriLUG: https://trilug.org/welcome
> --
> This message was sent to: William <william at trilug.org>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
> TriLUG mailing list : https://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web : https://www.trilug.org/mailman/options/trilug/william%40trilug.org
> Welcome to TriLUG: https://trilug.org/welcome
More information about the TriLUG
mailing list