Skip to content

Commit

Permalink
Reproduce bug
Browse files Browse the repository at this point in the history
  • Loading branch information
moessimple committed May 14, 2024
1 parent 2b2cc73 commit afd5bd1
Show file tree
Hide file tree
Showing 15 changed files with 553 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:hnmCfC2DAoRtcLQ3x6j37nn7tLl2CTk+4aVNptFhr1Q=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://bug-report.test

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Expand Down
21 changes: 21 additions & 0 deletions app/Console/Commands/ReproduceBugCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Console\Commands;

use App\Jobs\DeleteUserJob;
use App\Models\User;
use Illuminate\Console\Command;

class ReproduceBugCommand extends Command
{
protected $signature = 'reproduce-bug';

public function handle()
{
$this->call('migrate:fresh');

$this->call('db:seed');

dispatch(new DeleteUserJob(User::first()));
}
}
35 changes: 35 additions & 0 deletions app/Jobs/DeleteUserJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Jobs;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class DeleteUserJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

public bool $deleteWhenMissingModels = true;

public User $user;

/**
* Create a new job instance.
*/
public function __construct(User $user)
{
$this->user = $user;
}

/**
* Execute the job.
*/
public function handle(): void
{
$this->user->delete();
}
}
64 changes: 64 additions & 0 deletions app/Providers/TelescopeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;

class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
// Telescope::night();

$this->hideSensitiveRequestDetails();

$isLocal = $this->app->environment('local');

Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
return $isLocal ||
$entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}

/**
* Prevent sensitive request details from being logged by Telescope.
*/
protected function hideSensitiveRequestDetails(): void
{
if ($this->app->environment('local')) {
return;
}

Telescope::hideRequestParameters(['_token']);

Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}

/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*/
protected function gate(): void
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
//
]);
});
}
}
1 change: 1 addition & 0 deletions bootstrap/providers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

return [
App\Providers\AppServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
];
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"require": {
"php": "^8.2",
"laravel/framework": "^11.0",
"laravel/telescope": "^5.0",
"laravel/tinker": "^2.9"
},
"require-dev": {
Expand Down
71 changes: 70 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit afd5bd1

Please sign in to comment.