Source: martinjoo.dev

Blog for Laravel Artisans
On 15th of November I finally launched https://laracheck.io. If you're working in a team and you're about code quality, I think you're going to love it.

Consider this snippet: public function getTaskDefaultStatus(Project $project): string { $settings = json_decode($project->settings, true); if ($settings && is_array($settings) && array_key_exists('task_default_status', $settings)) { return $settings['task_default_status']; } else { return 'todo'; }}

I always preferred early returns: public function sendOverdueNotification(Task $task): void { if (!$task->overdue) { return; } $dependentTasks = []; if ($project->settings['notify_dependent_tasks']) { }

Another small thing I often overlook while reviewing code: return new class extends Migration { public function up() { Schema::create('posts', function (Blueprint $table) { $table->id(); $table->string('title'); $table->string('summary')->nullable()->default('null'); $table->string('body'); }); } public function down() { }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners