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

Arg 2 to Illuminate\Foundation\Application::make() must be of the type array, object given #94

Open
feenx opened this issue Jul 3, 2015 · 10 comments

Comments

@feenx
Copy link

feenx commented Jul 3, 2015

 [ErrorException]
  Argument 2 passed to Illuminate\Foundation\Application::make() must be of the type array, object given, called in
   /home/vagrant/code/g2anime/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 213 and de
  fined

I encountered this error when attempting to run php artisan larasearch:reindex --dir=app/Models but I didn't encounter any errors when running php artisan larasearch:paths --dir=app/Models. I looked at the files in question between Laravel v5.0 and v5.1 and didn't see any differences that could cause the issue and I have another app running Laravel v5.0 with no issues.

Any ideas @iverberk?

@florentsorel
Copy link

+1

@feenx
Copy link
Author

feenx commented Jul 3, 2015

Upon going through the error some more I've narrowed down the issue to this segment of code within SearchableTrait.php

public static function getProxy()
    {
        if (!static::$__es_proxy)
        {
            $instance = new static;

            if ($instance instanceof Model)
            {
                static::$__es_proxy = App::make('iverberk.larasearch.proxy', $instance);

                return static::$__es_proxy;
            } else
            {
                throw new \Exception("This trait can ony be used in Eloquent models.");
            }
        }

        return static::$__es_proxy;
    }

It seems the part static::$__es_proxy = App::make('iverberk.larasearch.proxy', $instance); is the problem. I don't know how this was done before though.

@lmahesh5
Copy link

lmahesh5 commented Jul 6, 2015

This was an old bug, since the owner is not responding at all, i have created a fork and fixed it.
https://github.com/lmahesh5/larasearch
Infact you can correct it in your package itself.
Just replace that line " static::$__es_proxy = App::make('iverberk.larasearch.proxy', $instance); "
with this line " static::$__es_proxy = new \Iverberk\Larasearch\Proxy($instance); " in SearchableTrait.php

@prigal
Copy link

prigal commented Jul 14, 2015

@lmahesh5, I try using your fork with "repositories" in my composer without success because you make your correction in dev-master and not in L5 branch :)

@pfeiferchristopher, your fork is ok (L5 branch is used)

@lmahesh5 @pfeiferchristopher, I still have un bug when trying to reindex :

vagrant@homestead:~/Projets/app$ php artisan larasearch:reindex App\\Product --relations
---> Reindexing App\Product



  [ErrorException]                                                                                                                                                                         
  Argument 1 passed to Illuminate\Database\Eloquent\Builder::parseRelations() must be of the type array, null given, called in /home/vagrant/Projets/app/vendor/laravel/framework/s  
  rc/Illuminate/Database/Eloquent/Builder.php on line 752 and defined                                                                                                                      

Any idea ?

@lmahesh5
Copy link

@pierrerigal If you are using a single table for indexing, then just "php artisan larasearch:reindex App\Models\index_model_name" is enough. But if you are using multiple tables (join) for indexing, then only that -- relations should be used, though i didnt tried it. My assumption based on the error it expects some parameters additionally for the --relations option (may be relative table names)

@Bouhnosaure
Copy link

I have the same error, i'm on Laravel 5.1

λ php artisan larasearch:reindex --relations --dir=App                                                                                                                                                             
---> Reindexing App\Equipment                                                                                                                                                                                      

  [ErrorException]                                                                                                                                                                                                 
  Argument 2 passed to Illuminate\Foundation\Application::make() must be of the type array, object given, called in C:\lamp\www\api-adv\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php o   
  n line 213 and defined                                                                                                                                                                                           

@dairton
Copy link

dairton commented Sep 3, 2015

Hi, i've got the same problem. I'm on Laravel 5.1

php artisan larasearch:reindex App\\Dispensa --relations
---> Reindexing App\Dispensa

  [ErrorException]
  Argument 1 passed to Illuminate\Database\Eloquent\Builder::parseRelations() must be of the type array, null given, called in /var/www/html/contratos/vendor/laravel/framework/src/Illuminate/Database/Eloq
  uent/Builder.php on line 755 and defined


@pierrerigal, Did you figure it out?
Thanks!

Edit: I got it. It was missing the --write-config option.

@lasselehtinen
Copy link

Having the same issue. Somebody wants to make a PR for this?

@kJamesy
Copy link

kJamesy commented Oct 14, 2015

This is a nice package, however the author should really update it to Laravel 5.1 or merge the PRs. Anyone wanna submit their L5.1 fork to packagist, otherwise? Thanking you...

Oh, just using the fork for the time being. Composer is really helpful.

@ghost
Copy link

ghost commented Feb 25, 2016

+1

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

8 participants