PHPackages                             k-a-tushar/bloodgroup-management - 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. k-a-tushar/bloodgroup-management

ActiveLibrary

k-a-tushar/bloodgroup-management
================================

Blood group management for Laravel apps

00PHP

Since Apr 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/K-A-Tushar/blood-group)[ Packagist](https://packagist.org/packages/k-a-tushar/bloodgroup-management)[ RSS](/packages/k-a-tushar-bloodgroup-management/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel BloodGroup Package
==========================

[](#laravel-bloodgroup-package)

A simple and reusable package for managing blood groups in Laravel applications.

Features
--------

[](#features)

- Easily manage blood groups with relations.
- Reusable code for any Laravel app with blood group management.
- Dynamically handle blood group assignments for models.
- Supports multiple models linked to a single blood group.

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

[](#installation)

1. Install the package via Composer:

```
composer require k-a-tushar/bloodgroup-management
```

2. Publish the package's configuration file:

```
php artisan vendor:publish --provider="Tushar\BloodGroup\BloodGroupServiceProvider" --tag="config"
```

3. The configuration file will be published to config/bloodgroup.php.

Configuration
-------------

[](#configuration)

In the config/bloodgroup.php file, you need to define the models that will be linked to the blood group. For example:

```
// config/bloodgroup.php

// Use the models that must have a "blood_group_id" field
return [
    'models' => [
        'user' => App\Models\User::class,
        'patient' => App\Models\Patient::class,
    ],
];
```

Here, we specify that User and Patient models are related to the BloodGroup model through the blood\_group\_id foreign key.

Customizing the Models You can add as many models as you need to the models array in config/bloodgroup.php.

The key used for each model should be lowercase (e.g., 'user', 'patient'), and it will be used for dynamic relationships like users and patients in your code.

Usage Using the HasBloodGroup Trait:

Add the HasBloodGroup trait to any model that should have a blood group. For example, in the User model:

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Tushar\BloodGroup\Traits\HasBloodGroup;

class User extends Model
{
    use HasBloodGroup;

    // Other model code
}
```

Working with Blood Groups:

You can now interact with the blood group like this:

```
// Assigning a blood group by name
$user = User::find(1);
$user->bloodGroup = 'O+';

// Getting the blood group name
echo $user->bloodGroup; // O+

// Removing the blood group
$user->removeBloodGroup();
```

Dynamic Relations:

You can access models related to blood groups dynamically. For example, you can access all users with a particular blood group:

```
$users = BloodGroup::where('name', 'O+')->first()->users; // Assuming 'O+' blood group exists
```

Similarly, you can define additional relationships for other models in your config/bloodgroup.php.

Example Configuration File: config/bloodgroup.php Here’s a sample configuration for managing multiple models:

```
// config/bloodgroup.php

return [
    // The models array where we define all models related to the blood group
    'models' => [
        'user' => App\Models\User::class,     // User model
        'patient' => App\Models\Patient::class, // Patient model
        'donor' => App\Models\Donor::class,    // Donor model (if needed)
    ],
];
```

Additional Features
-------------------

[](#additional-features)

### Validation:

[](#validation)

> Blood group names are validated for standard blood group types (e.g., A+, B-, O+).

### Dynamic Scopes:

[](#dynamic-scopes)

> You can use scopes such as whereBloodGroup to filter models by their blood group.

### License

[](#license)

> This package is open-sourced software licensed under the MIT license.

### Credits

[](#credits)

> Kawsar Ahmed - Author and Maintainer

```
এটি রিড মি ফাইলের একটি আপডেটেড সংস্করণ যা কনফিগারেশন এবং ব্যবহার সম্পর্কিত সমস্ত বিবরণ অন্তর্ভুক্ত করে। এতে কীভাবে কনফিগারেশন ফাইল তৈরি করবেন, কীভাবে মডেল সম্পর্কিত ডাইনামিক রিলেশন ব্যবহার করবেন, এবং অন্যান্য গুরুত্বপূর্ণ তথ্য রয়েছে।

```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5001221725edab71aa8d19a8990f7523d0b756af26db7be9898e7e4e2ded281a?d=identicon)[K-A-Tushar](/maintainers/K-A-Tushar)

---

Top Contributors

[![K-A-Tushar](https://avatars.githubusercontent.com/u/149403668?v=4)](https://github.com/K-A-Tushar "K-A-Tushar (6 commits)")

### Embed Badge

![Health badge](/badges/k-a-tushar-bloodgroup-management/health.svg)

```
[![Health](https://phpackages.com/badges/k-a-tushar-bloodgroup-management/health.svg)](https://phpackages.com/packages/k-a-tushar-bloodgroup-management)
```

PHPackages © 2026

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