PHPackages                             mortezaa97/brands - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mortezaa97/brands

ActiveLibrary

mortezaa97/brands
=================

v1.0.5(6mo ago)00MITPHPPHP ^8.2CI passing

Since Oct 24Pushed 6mo agoCompare

[ Source](https://github.com/mortezaa97/brands)[ Packagist](https://packagist.org/packages/mortezaa97/brands)[ Docs](https://github.com/mortezaa97/brands)[ RSS](/packages/mortezaa97-brands/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (8)Used By (0)

Brands Package
==============

[](#brands-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e29a128a15d712c9aca7ccbd198f1ab35cea1dd6be053a8076d5b597dd9bf938/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f7274657a616139372f6272616e64732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mortezaa97/brands)[![Total Downloads](https://camo.githubusercontent.com/60578c4c463874e535cbb0e386e7bbf2b829ded8b35447108ee84176df02a166/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f7274657a616139372f6272616e64732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mortezaa97/brands)

A Laravel package for managing product brands with full API support, authorization policies, and Filament integration.

Features
--------

[](#features)

- ✅ Complete CRUD operations for brands
- ✅ RESTful API endpoints with resource transformers
- ✅ Authorization policies for granular access control
- ✅ Soft deletes support
- ✅ Category relationships
- ✅ SEO-friendly with meta fields
- ✅ Slug-based routing
- ✅ User tracking (created by/updated by)
- ✅ Filament plugin ready
- ✅ API Resources for simple and detailed responses

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require mortezaa97/brands

```

### Service Provider Registration

[](#service-provider-registration)

The package will automatically register its service provider. If you need to manually register it, add the following to your `config/app.php`:

```
'providers' => [
    // ...
    Mortezaa97\Brands\BrandsServiceProvider::class,
],

```

### Publish Assets

[](#publish-assets)

Publish the configuration file:

```
php artisan vendor:publish --provider="Mortezaa97\Brands\BrandsServiceProvider" --tag="config"

```

Publish migrations (optional, migrations are loaded automatically):

```
php artisan vendor:publish --provider="Mortezaa97\Brands\BrandsServiceProvider" --tag="migrations"

```

### Run Migrations

[](#run-migrations)

Run the migrations to create the brands table:

```
php artisan migrate

```

Database Schema
---------------

[](#database-schema)

The brands table includes the following fields:

FieldTypeDescriptionidbigintPrimary keynamestringBrand nameslugstringURL-friendly identifierlogostring (nullable)Logo file pathstatussmallintBrand status (active/inactive)category\_idforeignId (nullable)Related categorydesclongText (nullable)Brand descriptionmeta\_titlestring (nullable)SEO meta titlemeta\_desclongText (nullable)SEO meta descriptionmeta\_keywordsstring (nullable)SEO keywordspage\_titlestring (nullable)Page display titlecolorstring (nullable)Brand color themecreated\_byforeignIdUser who created the brandupdated\_byforeignId (nullable)User who last updated the branddeleted\_attimestamp (nullable)Soft delete timestampcreated\_attimestampCreation timestampupdated\_attimestampLast update timestampConfiguration
-------------

[](#configuration)

The configuration file `config/brands.php` allows you to customize:

```
return [
    'table_name' => 'brands', // Customize table name if needed
];

```

Usage
-----

[](#usage)

### API Endpoints

[](#api-endpoints)

The package automatically registers the following API routes:

#### Get All Brands

[](#get-all-brands)

```
GET /api/brands

```

Returns a collection of brands with simple resource transformation.

**Response:**

```
[
    {
        "name": "Nike",
        "slug": "nike",
        "logo": "https://example.com/storage/logos/nike.png",
        "color": "#000000"
    }
]

```

#### Get Single Brand

[](#get-single-brand)

```
GET /api/brands/{slug}

```

Returns a detailed brand resource including category relationship.

**Response:**

```
{
    "name": "Nike",
    "slug": "nike",
    "logo": "https://example.com/storage/logos/nike.png",
    "desc": "Nike is a leading sportswear brand...",
    "meta_title": "Nike - Premium Sportswear",
    "meta_desc": "Discover Nike products...",
    "meta_keywords": "nike, sportswear, shoes",
    "page_title": "Nike Official Store",
    "color": "#000000",
    "category": {
        "id": 1,
        "name": "Sportswear",
        "slug": "sportswear"
    }
}

```

### Using in Your Code

[](#using-in-your-code)

#### Create a Brand

[](#create-a-brand)

```
use Mortezaa97\Brands\Models\Brand;

$brand = Brand::create([
    'name' => 'Adidas',
    'slug' => 'adidas',
    'logo' => 'path/to/logo.png',
    'status' => Status::ACTIVE,
    'category_id' => 1,
    'desc' => 'Premium sportswear brand',
    'meta_title' => 'Adidas Official',
    'color' => '#000000',
    'created_by' => auth()->id(),
]);

```

#### Query Brands

[](#query-brands)

```
// Get all active brands
$brands = Brand::all();

// Get brand by slug
$brand = Brand::where('slug', 'nike')->first();

// Get brands with category
$brands = Brand::with('category')->get();

// Get brands created by specific user
$brands = Brand::whereHas('createdBy', function($query) {
    $query->where('id', 1);
})->get();

```

#### Update a Brand

[](#update-a-brand)

```
$brand = Brand::find(1);
$brand->update([
    'name' => 'Updated Brand Name',
    'updated_by' => auth()->id(),
]);

```

#### Delete a Brand (Soft Delete)

[](#delete-a-brand-soft-delete)

```
$brand = Brand::find(1);
$brand->delete(); // Soft delete

// Restore
$brand->restore();

// Force delete
$brand->forceDelete();

```

### Relationships

[](#relationships)

The Brand model includes the following relationships:

#### Category

[](#category)

```
$brand = Brand::with('category')->first();
$categoryName = $brand->category->name;

```

#### Created By User

[](#created-by-user)

```
$brand = Brand::with('createdBy')->first();
$creatorName = $brand->createdBy->name;

```

#### Updated By User

[](#updated-by-user)

```
$brand = Brand::with('updatedBy')->first();
if ($brand->updatedBy) {
    $updaterName = $brand->updatedBy->name;
}

```

### Authorization

[](#authorization)

The package includes a `BrandPolicy` for authorization. The following gates are available:

- `viewAny` - View list of brands
- `view` - View single brand
- `create` - Create new brand
- `update` - Update existing brand
- `delete` - Delete brand
- `restore` - Restore soft-deleted brand
- `forceDelete` - Permanently delete brand

Example usage in your controllers:

```
use Illuminate\Support\Facades\Gate;

// Check if user can view brands
if (Gate::allows('viewAny', Brand::class)) {
    // User can view brands
}

// Authorize specific brand action
Gate::authorize('update', $brand);

```

### API Resources

[](#api-resources)

The package provides two resource transformers:

#### BrandResource

[](#brandresource)

Full details including relationships and SEO fields.

```
use Mortezaa97\Brands\Http\Resources\BrandResource;

return new BrandResource($brand);

```

#### BrandSimpleResource

[](#brandsimpleresource)

Simplified response for list views.

```
use Mortezaa97\Brands\Http\Resources\BrandSimpleResource;

return BrandSimpleResource::collection($brands);

```

### Filament Integration

[](#filament-integration)

To integrate with Filament, register the plugin in your panel provider:

```
use Mortezaa97\Brands\BrandsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            BrandsPlugin::make(),
        ]);
}

```

Facade
------

[](#facade)

You can use the Brands facade for convenient access:

```
use Mortezaa97\Brands\BrandsFacade as Brands;

// Use the facade
Brands::someMethod();

```

Global Scope
------------

[](#global-scope)

The Brand model includes a global scope that orders all queries by `created_at` in descending order (newest first).

Testing
-------

[](#testing)

```
composer test

```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Morteza Jafari](https://github.com/mortezaa97)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance69

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

6

Last Release

183d ago

PHP version history (2 changes)v1.0.0PHP ^7.4|^8.0

v1.0.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb4593fe9950cffcc4459b71bbd4aa5f378c28c8e546dffb8981898f31ed8b26?d=identicon)[mortezajafari76](/maintainers/mortezajafari76)

---

Top Contributors

[![mortezaa97](https://avatars.githubusercontent.com/u/57325086?v=4)](https://github.com/mortezaa97 "mortezaa97 (6 commits)")

---

Tags

mortezaa97brands

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mortezaa97-brands/health.svg)

```
[![Health](https://phpackages.com/badges/mortezaa97-brands/health.svg)](https://phpackages.com/packages/mortezaa97-brands)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

71510.9M66](/packages/laravel-mcp)[illuminate/view

The Illuminate View package.

13144.9M1.7k](/packages/illuminate-view)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
