[TriLUG] Fighting a Laravel error. Help?

Scott Lambdin via TriLUG trilug at trilug.org
Wed Jan 25 12:01:25 EST 2023


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


More information about the TriLUG mailing list