Laravel is full of hidden gems that can make your development smoother. Today, I want to highlight two handy features you might not know about:
1οΈβ£ numerify in Eloquent Factories
The numerify method from Faker lets you replace # characters with random digits.
public function definition(): array
{
return [
'phone' => $this->faker->numerify('+##'), // Example output: +20
];
}
2οΈβ£ invisible in Migrations
The invisible column modifier hides a column from default SELECT queries while keeping it in the database.
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
Schema::create('users', function (Blueprint $table) {
$table->timestamp('email_verified_at')
->nullable()
->invisible();
});
π Find more tips and share your knowledge here:
https://github.com/digging-code-blog
Top comments (0)