laravellaravel-5telescopemoloquent

How to use telescope with moloquent / mongodb?


Showing Error

{message: "Call to a member function prepare() on null",…} exception: "Symfony\Component\Debug\Exception\FatalThrowableError" file: "/var/www/html/broc/vendor/laravel/framework/src/Illuminate/Database/Connection.php" line: 326 message: "Call to a member function prepare() on null" trace: [,…]


Solution

  • Firstly you need to debug that you are using correct DB.

    FIle:

    vendor/laravel/telescope/src/Http/Controllers/EntryController.php
    function : index()
    
    dd($storage)  //show dump 
    

    Output should be :

    DatabaseEntriesRepository {#1671 #connection: "mongodb"
    #monitoredTags: null }

    After that

    You need to extend EntryModel which is in the vendor/laravel/telescope/src/Storage/DatabaseEntriesRepository.php

    location of the telescope package and set moloquent connection there.

    now should be use Moloquent instead of Eloquent used like that

    //use Illuminate\Database\Eloquent\Model;
    
    use Moloquent as Model;
    
    class EntryModel extends Model
    

    For more detail follow below link

    https://thewebtier.com/php/complete-guide-for-implementing-laravel-telescope-with-mongodb/