This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Garfild
Garfild
"Call to undefined method October\Rain\Database\QueryBuilder::instance()" on line 1999 of /home/garf/www/nosgoth/public_html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php

This shows me on the backend page. Without any stacktrace. Only like alert bar with only this message on backend/ I don't know what to do. Checked all the files of my plugin.

alxy
alxy

If you want to see the stack trace, you can go to Settings > Event log.

If you need further help, you need to provide some code.

daftspunky
daftspunky

Could be an issue with some plugin you have installed, can you list the plugins that you are using?

smarbos8491
smarbos8491

Im getting the same problem.


"Call to undefined method October\Rain\Database\QueryBuilder::instance()" on line 1999 of /var/www/html/october4.com/public_html/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php

What's wrong? There are no errors in the Event Log.

Last updated

smarbos8491
smarbos8491

I create a new plugin, then i create a new model "settings" and when i go to the backend and enter the settings of the plugin, then the error shwows.

AlecSPB
AlecSPB

Has anyone found a solution to this problem?

Dbdojo
Dbdojo

Hey guys! Hello to all :)

I confirm to be able to fix the error, and then recreate it so as to identify what it was that in that case I gave the same result.

I get the same error described, during developmente and view of this error, this type of error i've see was not detected Event log, insteade the error make with bash, or termina command line.

I was reading:

http://www.sitepoint.com/building-octobercms-plugins-google-analytics/

Following the excellent article in paragraph ' Using Settings ' shows how to customize the model of the plugin, then reach the ultimate goal of the article.

The problem in the middle is that I had not the model class of the plugin, so I gave it to resolve to generate it:

php artisan created: model Dbdojo.Dbdojotest

and looking at them in the backend I get the error described. ( ...... QueryBuilder :: Instance () on line 1999 )

Looking at the model generated I saw that inside there are the basic lines:


    /**
     * @var string The database table used by the model.
     */
    public $table = 'dbdojo_dbdojotest_impostazionis';

    /**
     * @var array Guarded fields
     */
    protected $guarded = ['*'];

    /**
     * @var array Fillable fields
     */
    protected $fillable = [];

    /**
     * @var array Relations
     */
    public $hasOne = [];
    public $hasMany = [];
    public $belongsTo = [];
    public $belongsToMany = [];
    public $morphTo = [];
    public $morphOne = [];
    public $morphMany = [];
    public $attachOne = [];
    public $attachMany = [];

At this point i've resolved reading here : https://octobercms.com/docs/plugin/settings#database-settings I tried it and it worked, to give a proper configuration must include at least three fields, place my example:

    public $implement = ['System.Behaviors.SettingsModel'];
    public $settingsCode = 'Dbdojo_Dbdojotest_Settings';
    public $settingsFields = 'fields.yaml';

so in general:

    public $implement = ['System.Behaviors.SettingsModel'];
    public $settingsCode = 'AuthorName_PluginName_Settings';
    public $settingsFields = 'fields.yaml';

To ensure that everything is working properly the three lines of the model structure must have to be so, while respecting the structure of the $settingsCode, leaving intact the final part : "_Settings"

It also works with : "_settings"

It's independent of the file name, the file in my example is called 'Impostazioni.php', and also the class of the model is called the 'Impostazioni'.

( For force the test i have mainteined the file name and the file of the class in my exactly language word, italian, impostazioni.php and Impostazioni )

I respected the rule of the folder name matches the name of the file in lower case etvoila! It works perfectly :) .

The error is then due to the lack of reference implementation useful for action.

In the generated code of the base is the reference for the use of the database, then depending on how you want to proceed, can be used or not that part. As from indicated class works fine without. :)

The full code of the working class (with the pre-generated, commented lines used in a test ):

Name file: Impostazioni.php

File content :


namespace Dbdojo\Dbdojotest\Models;
use Model;

class Impostazioni extends Model
{

    // /**
    //  * @var string The database table used by the model.
    //  */
    // public $table = 'dbdojo_dbdojotest_impostazioni';

    // /**
    //  * @var array Guarded fields
    //  */
    // protected $guarded = ['*'];

    // /**
    //  * @var array Fillable fields
    //  */
    // protected $fillable = [];

    // /**
    //  * @var array Relations
    //  */
    // public $hasOne = [];
    // public $hasMany = [];
    // public $belongsTo = [];
    // public $belongsToMany = [];
    // public $morphTo = [];
    // public $morphOne = [];
    // public $morphMany = [];
    // public $attachOne = [];
    // public $attachMany = [];

    public $implement = ['System.Behaviors.SettingsModel'];
    public $settingsCode = 'Dbdojo_Dbdojotest_Settings';
    public $settingsFields = 'fields.yaml';

}

I really love October, really Thank you so much!!!! to Aleksey and Samuel, for this fabulous, very beautiful, amazing, incredible , ........ opera :)!!!

Have ever a good day Bye bye Dbdojo

p.s. Excuse my English

P.p.s.

Post the content of the file field, rif in the subfolder impostazioni, in my example my field name is ' Autore '

# ===================================
#  Form Field Definitions
# ===================================

fields:
    autore:
        label: Autore

Last updated

1-7 of 7

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.