jeudi 30 juin 2022

How to allow websockets through a Laravel 5.8 maintenance page?

I need to allow websockets wss:// through the maintenance mode with Laravel 5.8 as:

php artisan down --allow=xxx.xxx.xx.xx




php artisan down --allow=127.0.0.1

But no luck.

Any clever ideas please? Is there a way to allow on Laravel 5.8 a protocol like wss:// ? I cannot work out why the Laravel maintenance page blocks it. As soon as it is up, the websockets work again.

Thanks



via Chebli Mohamed

Laravel 5.4 - remember me and custom session values issue

I get project that has custom values in sessions. I use Remember me option, and every time when session is expired, new session is created (regenerated).

Now, I have problem because I need to keep all data from main session (first created) and keep values for all time that user is logged in .

Example:

if (Auth::attempt(['email' => $email, 'password' => $password], $rememberMe)) {
    $data = [
        'unread_messages'         => $message->unread_messages,
        'unread_worker_messages'  => $message->unread_worker_messages,
        'unread_poll'             => $message->unread_poll
        ];
        
        session(['num_unread_message' => $data]);
}

Now, when the session is expired after 2 hours, user will be logged, because Remember me is TRUE, but the values in Session get vanished.

I need to keep all of values in the new session that will be created after regeneration.



via Chebli Mohamed

mardi 28 juin 2022

Pusher In Laravel With Apiato

I Try manythinhg but still got error in pusher. This is very Common Error. Pusher/Pusher class not found. I try below i mention.

add class in config/app line 253) code : 'Pusher' => Pusher\Pusher::class

composer dump-autoload -> Output 0

Vendor directory delete -> composer install-> composer update

Accroding blog https://stackoverflow.com/questions/45052853/class-pusher-not-found-> PusherBroadCaster search and rename with Pusher-> output 0

Try to install pusher 7.0 output = error

Add Manually path->composer update-> output 0 and I Am use Laravel '5.5' with apiato core '2.2.6' and my pusher package version is '2.6'



via Chebli Mohamed

lundi 27 juin 2022

real time - browser

i have a problem, my search engine only searches with a particular Model

Model: 'Registro'

 public function search(Request $request){
        
        $results = Registro::where('cliente', 'LIKE', "%{$request->search}%")->get();
        
        return view('posts.results', compact('results'))->with(['search' => $request->search])->render();
        
    }

How can I make the search engine work with more Models?



via Chebli Mohamed

dimanche 26 juin 2022

Laravel RefreshDatabase doesn't work in testing

In order to move my current Laravel 5.5 project to the latest version, I was trying to setup some tests (I've never done that before).

To do so, I added <env name="DB_CONNECTION" value="mysql_testing" /> in the phpunit.xml, under the <php> section, and created a copy of the current mysql configuration under config/database.php naming it mysql_testing, which has 'database' => env('DB_NAME_TESTING', 'forge') .

In the .env file I put DB_NAME_TESTING=testDB. The database exists, is empty and the user has all permissions on it.

I haven't created any Test, yet, just tried the Examples provided by Laravel. If I run the tests as they are, they all pass. If I add the RefreshDatabase trait on them, instead, I get

ErrorException : Trying to access array offset on value of type int
C:\[path to project]\vendor\symfony\console\Input\ArrayInput.php:135

which corresponds to } elseif ('-' === $key[0]) {.

After a bit of tracing, I found out that the $key is 'migrate:fresh', which is the Artisan command that RefreshDatabase is trying to run. In later versions this segment has been replaced with } elseif (str_starts_with($key, '-')) {, but this is only available since PHP 8, and I'm currently stuck with PHP 7.4.

My question now is: what am I doing wrong in setting up my testing database?



via Chebli Mohamed

samedi 25 juin 2022

ErrorException Undefined variable: users (View: resources\views\admin\dashboard.blade.php)

hi I wants to show users list into my dashboard pannel but it shows me this problem :

ErrorException Undefined variable: users (View: resources\views\admin\dashboard.blade.php)

Controller File :

 public function index()
{
    $listuser = User::all();
    return view('admin.dashboard',['users' => $listuser]);
    //return view('admin.dashboard')->with('users', $listuser);
}

blade file :

 <div id="utilisateurs">
                            <table width="100%" cellspacing="0" border="1">
                                    <thead>
                                        <tr>
                                            <th>Id</th>
                                            <th>Nom et Prenom</th>
                                            <th>Email</th>
                                            <th>tele</th>
                                            <th>adresse</th>
                                            <th>date de creation</th>
                                            <th>Statut de compte</th>
                                        </tr>
                                    </thead><br>
                                    <tbody>
                                        
                                        @foreach($users as $user)
                                            @if($user->role_as=='0')
                                        <tr>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td></td>
                                            <td>Null</td>
                                        </tr>
                                            @endif
                                        @endforeach
                                    </tbody>
                            </table>
                        </div>

Routes :

  Route::middleware(['auth','isAdmin'])->group(function() {
Route::get('/dashboard','Admin\FrontendController@index');


/*users routes*/
Route::get('/dashboard', 'UserController@index');


via Chebli Mohamed

vendredi 24 juin 2022

I install the flutterwave package in laravel 8 and 9 but facing this issue

i run this command

composer install flutterwavedev/flutterwave-v3

give me this error.

Invalid argument flutterwavedev/flutterwave-v3. Use "composer require flutterwavedev/flutterwave-v3" instead to add packages to your composer.json.

when we run this command "composer require flutterwavedev/flutterwave-v3".

Your requirements could not be resolved to an installable set of packages.

Problem 1 - flutterwavedev/flutterwave-v3 1.0.0 requires monolog/monolog 1.* -> found monolog/monolog[1.0.0-RC1, ..., 1.x-dev] but the package is fixed to 2.6.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. - flutterwavedev/flutterwave-v3 1.0.1 requires vlucas/phpdotenv ^2.5 -> found vlucas/phpdotenv[v2.5.0, ..., 2.6.x-dev] but the package is fixed to v5.4.1 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. - Root composer.json requires flutterwavedev/flutterwave-v3 ^1.0 -> satisfiable by flutterwavedev/flutterwave-v3[1.0.0, 1.0.1].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require flutterwavedev/flutterwave-v3:*" to figure out if any version is installable, or "composer require flutterwavedev/flutterwave-v3:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.



via Chebli Mohamed