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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners