PHP code example of pfrug / laravel-debug-helpers

1. Go to this page and download the library: Download pfrug/laravel-debug-helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pfrug / laravel-debug-helpers example snippets


use LaravelDebugHelpers\SqlHelper;

// Complex query with joins and subqueries
$query = User::join('profiles', 'users.id', '=', 'profiles.user_id')
            ->leftJoin('organizations', 'users.organization_id', '=', 'organizations.id')
            ->whereHas('roles', function($q) {
                $q->whereIn('name', ['admin', 'moderator']);
            })
            ->where('users.status', 'active')
            ->where('users.email_verified_at', '!=', null)
            ->where(function($q) {
                $q->where('profiles.is_public', 1)
                  ->orWhere('users.account_type', 'premium');
            })
            ->where('organizations.country', 'US')
            ->where('users.created_at', '>=', now()->subMonths(6))
            ->select('users.id', 'users.name', 'users.email', 'profiles.bio', 'organizations.name as org_name')
            ->orderBy('users.created_at', 'desc')
            ->limit(25);

SqlHelper::sqlFromBindings($query);

'providers' => [
    LaravelDebugHelpers\DevUtilsServiceProvider::class,
],