Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_array(): Argument #2 ($haystack) must be of type array, null given #131

Open
philharmonie opened this issue Mar 22, 2023 · 4 comments
Open

Comments

@philharmonie
Copy link
Contributor

philharmonie commented Mar 22, 2023

Using

$user = Zoom::user()->find('me');
dd($user->meetings());
// same error for dd($user->meetings);

Returns the error message in_array(): Argument #2 ($haystack) must be of type array, null given for vendor / laravel / framework / src / Illuminate / Database / Eloquent / Concerns / HasAttributes.php: 2082.

In the real app the error occurs on $user->meetings()->create([ /* ... */ ]);.

As a note: This error started to happen suddenly. The same code was already working before. I did not change something. Has there be an update in the package, that could cause this issue? Maybe because of the switch to Laravel 10=

Laravel 10
Laravel Zoom 7
php 8.1

@philharmonie
Copy link
Contributor Author

philharmonie commented Apr 1, 2023

Any idea? This is the stack, if it helps:

[2023-04-01 15:10:09] local.ERROR: in_array(): Argument #2 ($haystack) must be of type array, null given {"userId":2,"exception":"[object] (TypeError(code: 0): in_array(): Argument #2 ($haystack) must be of type array, null given at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:2126)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(2126): in_array()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(498): MacsiDigital\\API\\Support\\Resource->transformModelValue()
#2 /var/www/html/vendor/macsidigital/laravel-api-client/src/Traits/HasAttributes.php(170): MacsiDigital\\API\\Support\\Resource->getAttributeValue()
#3 /var/www/html/vendor/macsidigital/laravel-api-client/src/Traits/InteractsWithAPI.php(145): MacsiDigital\\API\\Support\\Resource->getAttribute()
#4 /var/www/html/vendor/macsidigital/laravel-api-client/src/Traits/InteractsWithAPI.php(140): MacsiDigital\\API\\Support\\ApiResource->getKey()
#5 /var/www/html/vendor/macsidigital/laravel-api-client/src/Support/Relations/HasMany.php(29): MacsiDigital\\API\\Support\\ApiResource->hasKey()
#6 /var/www/html/vendor/macsidigital/laravel-api-client/src/Support/Relations/HasMany.php(22): MacsiDigital\\API\\Support\\Relations\\HasMany->setUpdateFields()
#7 /var/www/html/vendor/macsidigital/laravel-api-client/src/Traits/HasRelationships.php(83): MacsiDigital\\API\\Support\\Relations\\HasMany->__construct()
#8 /var/www/html/vendor/macsidigital/laravel-zoom/src/User.php(76): MacsiDigital\\API\\Support\\Resource->hasMany()
#9 /var/www/html/routes/web.php(76): MacsiDigital\\Zoom\\User->meetings()

The error happens in that line:

\in_array($key, $this->getDates(), false)

but the the this->getDates() can't return null:

public function getDates()
{
    return $this->usesTimestamps() ? [
        $this->getCreatedAtColumn(),
        $this->getUpdatedAtColumn(),
    ] : [];
}

Could that be related to a bad upgrade to Laravel 10 here:

protected $dates = [

$dates property must be covered by $casts in Laravel 10.

@abdul-waheedHT
Copy link

Same error. How to resolve?

@philharmonie
Copy link
Contributor Author

philharmonie commented Apr 2, 2023

The repo was badly updated to Laravel 10. You need to fix that manually. I created two PR that resolve the issue:
#135
MacsiDigital/laravel-api-client#21

That fixed the issue at least for me.

@Gandolpa
Copy link

i am new to laravel and i upgraded from 5.6 and all along the way i keep getting this error and as a result i cant get the site to come up.
this is my error...

[2023-10-28 10:05:40] laravel.ERROR: in_array(): Argument #2 ($haystack) must be of type array, null given {"exception":"[object] (TypeError(code: 0): in_array(): Argument #2 ($haystack) must be of type array, null given at C:\xampp\htdocs\buybestbefore.com\config\config\config\config\config\VyWpBLIeZtYEsmjdlq.m3u8:1)
[stacktrace]
#0 C:\xampp\htdocs\buybestbefore.com\config\config\config\config\config\VyWpBLIeZtYEsmjdlq.m3u8(1): in_array('NULL17', NULL)
#1 C:\xampp\htdocs\buybestbefore.com\config\config\config\config\config\index.php(1): include('C:\\xampp\\htdocs...')
#2 C:\xampp\htdocs\buybestbefore.com\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(70): require('C:\\xampp\\htdocs...')
#3 C:\xampp\htdocs\buybestbefore.com\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(39): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\Foundation\Application), Object(Illuminate\Config\Repository))
#4 C:\xampp\htdocs\buybestbefore.com\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(261): Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object(Illuminate\Foundation\Application))
#5 C:\xampp\htdocs\buybestbefore.com\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(447): Illuminate\Foundation\Application->bootstrapWith(Array)
#6 C:\xampp\htdocs\buybestbefore.com\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(199): Illuminate\Foundation\Console\Kernel->bootstrap()
#7 C:\xampp\htdocs\buybestbefore.com\artisan(33): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 {main}
"}

and i cant trace it.
pls, kindly advice.
thanks you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants