Gurmandeep Singh
@iamgurmandeep
Followers
809
Following
2K
Media
270
Statuses
630
Sr. Software Engineer
Joined June 2012
π New in #Laravel: Use `whenTableHasIndex()` and `whenTableDoesntHaveIndex()` to run logic based on whether your DB table already has an index. Perfect for safer migrations.
0
0
1
#Laravel Tip π In Laravel 12, you can automatically cast Eloquent attributes to HTML strings using `AsHtmlString::class`.
1
4
99
#Laravel Tip π In Laravel 12, you can use the `toResource()` helper directly on your Eloquent models. Just fetch your data, and instantly convert it into a clean, structured API resource.
4
6
133
#PHP Tip π In PHP 8.3, you can use the `json_validate()` function, a super easy way to check if a string is valid JSON.
0
1
4
#Laravel Tip π In Laravel, the `Arr::hasAll` method allows you to check if all the specified keys are present in an array. It supports nested keys using dot notation and returns true only if every key exists.
0
9
83
#Laravel Tip π The `Str::mask` method hides part of a string by replacing it with a repeated character, making it useful for covering things like emails or phone numbers.
3
15
127
#Laravel Tip π You can use the `whenEmpty` method to run a callback if the collection is empty.
0
1
8
#Laravel Tip π₯ In Laravel, you can use the `whenNotExactly` method to execute a callback if a string is not an exact match, and you can add a second callback to execute if the string is an exact match.
0
1
6
#Laravel Tip π In Laravel, the `Number` class provides a `currency` method that formats currencies with locale support.
0
0
3
#Laravel Tip π In Laravel, the whereAny method allows you to search across multiple columns using OR logic.
0
0
8
#Laravel Tip π if you only need a custom rule once, use a closure instead of a rule class. The closure gets the field name, its value, and a fail() callback for invalid data.
0
0
5
#Laravel Tip π Laravel introduced a new collection method `toPrettyJson`, which formats the collection as a neatly indented JSON string using PHP's JSON_PRETTY_PRINT option. https://t.co/RRYRxhFiTM
0
1
9
#Laravel Tip π₯ You can use `incrementEach()` method to increment multiple columns with a single query.
0
6
64
#Laravel Tip π₯ You can use the 'replicate' method to create the unsaved copy of the existing model instance.
1
5
90
#Laravel Tip π `withWhereHas()` method simplifies cases where you have to repeat code used to both filter with `whereHas()` and select the same record via `with()`.
0
0
4
#CSS Tip π₯ You can use the `text-wrap: pretty` property to improve text layout. It helps create cleaner body copy with smoother line breaks and fewer orphaned words.
0
0
5
#Laravel Tip π You can use `required_if_accepted` validation rule which ensures the field under validation is required if another field is accepted (a value of yes, on, 1, or true).
0
0
1
#Laravel Tip π To apply default settings to every outgoing HTTP request, call the `globalOptions` method within the boot method of your AppServiceProvider.
0
0
1
In #Laravel, the HasMiddleware interface lets you attach middleware directly to a controller. To use it, implement a static middleware method in your controller. This method should return an array of the middleware you want to apply to the controllerβs actionsπ
0
0
1