got error in php artisan nationals:start - commands show in list
Closed this issue · 7 comments
[2018-06-09 17:21:03] local.ERROR: Argument 1 passed to Illuminate\Database\Eloquent\Builder::create() must be of the type array, string given, called in C:\xampp\htdocs\sukem\day 1\task1\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1509 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 1 passed to Illuminate\\Database\\Eloquent\\Builder::create() must be of the type array, string given, called in C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Model.php on line 1509 at C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Builder.php:752) [stacktrace] #0 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Model.php(1509): Illuminate\\Database\\Eloquent\\Builder->create('You have exceed...') #1 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Model.php(1521): Illuminate\\Database\\Eloquent\\Model->__call('create', Array) #2 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\3assy2018\ ationals\\src\\console\\AllCountriesCommand.php(47): Illuminate\\Database\\Eloquent\\Model::__callStatic('create', Array) #3 [internal function]: m3assy\ ationals\\console\\AllCountriesCommand->handle() #4 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(29): call_user_func_array(Array, Array) #5 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #6 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #7 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(564): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #8 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(184): Illuminate\\Container\\Container->call(Array) #9 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\symfony\\console\\Command\\Command.php(251): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #10 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Command.php(171): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #11 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\symfony\\console\\Application.php(886): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #12 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\symfony\\console\\Application.php(262): Symfony\\Component\\Console\\Application->doRunCommand(Object(m3assy\ ationals\\console\\AllCountriesCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #13 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\symfony\\console\\Application.php(145): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #14 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Console\\Application.php(89): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #15 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php(122): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #16 C:\\xampp\\htdocs\\sukem\\day 1\\task1\\artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #17 {main} "}
The package relies on constant api key so it has exceeded the daily request .. the documentation will be updated today with the new updates.
Thanks for notice
You can now try and tell me if the problem exists or not.
Hey Hii
i created new project and again import library and perform command but still same error got
` Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to Illuminate\Database\Eloquent\Builder::c
reate() must be of the type array, string given, called in C:\xampp\htdocs\sukem\day 1\Task2\vendor\laravel\framework\sr
c\Illuminate\Database\Eloquent\Model.php on line 1509
at C:\xampp\htdocs\sukem\day 1\Task2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php:752
748| *
749| * @param array $attributes
750| * @return \Illuminate\Database\Eloquent\Model|$this
751| */
752| public function create(array $attributes = [])
753| {
754| return tap($this->newModelInstance($attributes), function ($instance) {
755| $instance->save();
756| });
Exception trace:
1 Illuminate\Database\Eloquent\Builder::create("You have exceeded your daily API key usage limit (500). Please read
the documentation for more information.")
C:\xampp\htdocs\sukem\day 1\Task2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1509
2 Illuminate\Database\Eloquent\Model::__call("create")
C:\xampp\htdocs\sukem\day 1\Task2\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1521
`
also got error in this command ( php artisan region:add --code=[+91] )
` php artisan region:add --code=[+91]
ErrorException : Invalid argument supplied for foreach()
at C:\xampp\htdocs\sukem\day 1\Task2\vendor\3assy2018\nationals\src\console\AddCitiesCommand.php:68
64| foreach ($cities as $code){
65| $country = Country::where('code', $code)->get()->first()
;
66| $response= Curl::to("https://battuta.medunes.net/api/reg
ion/{$code}/all/?key=85d97f67ff7fd1935b314ec4f884ad33")->get();
67| $result_cities= json_decode($response, true);
68| foreach ($result_cities as $result_city){
69| $added_city = new Region($result_city);
70| $country->regions()->save($added_city);
71| }
72| $this->info("Regions of {$country->name} has been added
successfully");
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Invalid argument supplied for foreach()", "C:\xampp
\htdocs\sukem\day 1\Task2\vendor\3assy2018\nationals\src\console\AddCitiesCommand.php")
C:\xampp\htdocs\sukem\day 1\Task2\vendor\3assy2018\nationals\src\console\AddCitiesCommand.php:68
2 m3assy\nationals\console\AddCitiesCommand::handle()
C:\xampp\htdocs\sukem\day 1\Task2\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29
Please use the argument -v to see more details.
`
I see .. the error was solved but the package wasn't updated at the time you tried again at packagist .. try again now .. It works with me .. I added a new master api key to solve the problem.
Thanks ! it is done
i update composer and it will work with new packagist ..
countries successfully added in table but in region some error got while perform command for region add to table
`C:\xampp\htdocs\sukem\day 1\Task2> php artisan region:add --code=[in]
ErrorException : Invalid argument supplied for foreach()
at C:\xampp\htdocs\sukem\day 1\Task2\vendor\3assy2018\nationals\src\console\AddCitiesCommand.php:68
64| foreach ($cities as $code){
65| $country = Country::where('code', $code)->get()->first()
;
66| $response= Curl::to("https://battuta.medunes.net/api/reg
ion/{$code}/all/?key=" . config('nationals.battuta.apiKey'))->get();
67| $result_cities= json_decode($response, true);
68| foreach ($result_cities as $result_city){
69| $added_city = new Region($result_city);
70| $country->regions()->save($added_city);
71| }
72| $this->info("Regions of {$country->name} has been added
successfully");
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Invalid argument supplied for foreach()", "C:\xampp
\htdocs\sukem\day 1\Task2\vendor\3assy2018\nationals\src\console\AddCitiesCommand.php")
C:\xampp\htdocs\sukem\day 1\Task2\vendor\3assy2018\nationals\src\console\AddCitiesCommand.php:68
2 m3assy\nationals\console\AddCitiesCommand::handle()
C:\xampp\htdocs\sukem\day 1\Task2\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29
Please use the argument -v to see more details.
`
Add the region code like this
php artisan region:add --code=in
not --code=[in]
Thanks ! It is working Now 👍