data_forget Helper for Laravel
Since Laravel version 10.15, there is a new utility function called data_forget that allows you to remove keys from an array or object using a "dot" notation.
If you ever need to add extra details to a model (like a product in an online store), the Laravel Attributes package makes it really easy.
For example, imagine you're running an online shop and want to include technical information about your products. With this package, you can do it easily like this:
composer require milwad/laravel-attributes
After publish config files.
php artisan vendor:publish --provider="Milwad\LaravelAttributes\LaravelAttributesServiceProvider"
After publish, you migrate the migration file.
php artisan migrate
Add Trait to Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Milwad\LaravelAttributes\Traits\Attributable;
class Product extends Model
{
use HasFactory, Attributable;
}
Now lets add attach the attributes to a specific model
$product = Product::query()->create([
'name' => 'Iphone',
'content' => 'text',
]);
$data = [
[
'title' => 'display',
'value' => '6.5‑inch Retina display',
],
[
'title' => 'capacity',
'value' => '64GB, 256GB',
],
[
'title' => 'height',
'value' => '4.8 inches',
],
[
'title' => 'width',
'value' => '4.8 inches',
],
];
$product->attachAttributes($data);
Now whenever we want to fetch the attributes records we can do it
$product = Product::query()->with('attributes')->get();
$product->attributes
For complete details check out the package on GitHub.
Full-stack developer with a knack for Merging creativity with technical expertise for standout solutions.
Since Laravel version 10.15, there is a new utility function called data_forget that allows you to remove keys from an array or object using a "dot" notation.
The ChatGPT Laravel API Package Generator package for Laravel generates smart API mocks in Laravel using ChatGPT prompts:
You can make your Laravel app multi-tenant using the Tenancy for Laravel Tenant package. This tenancy package lets you make any Laravel application multi-tenant without rewriting it.
Are you ready to take your Laravel skills to the next level and build extraordinary applications? Look no further! In this blog post, we will unveil a treasure trove of top packages that will revolutionize your development process.
The Livewire Tables package brings dynamic tables for models to Laravel Livewire. These are some of the features which you will get out of the box:
The MJML PHP package by Spatie can help you create email templates more easily. But there is a catch. It can be difficult to craft visually appealing and functional email templates that work across a variety of email clients.
Subscribe for 20+ new Laravel tutorials every week
You can unsubscribe at any time. You'll also get -20% off my courses!