megapixel23/belongs-to-one
Larablocks Analysis
megapixel23/belongs-to-one works with Laravel 5 (latest release 2.0.0, Dec 16, 2017), which reached end of life: no more fixes, even for security.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 5, past end of life
- No release in the last 12 months (last: Dec 16, 2017)
- 7 downloads a month (needs 10,000)
- 7 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Dec 16, 2017.
- No releases in the last 12 months.
- First released: May 13, 2017.
- Monthly downloads: 7, up 133% from six months ago.
- 1 open issue on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.
| Install | |
|---|---|
composer require megapixel23/belongs-to-one |
|
| Latest Version: | 2.0.0 |
| Laravel: | 5 |
| License: | MIT |
| Last Updated: | Dec 16, 2017 |
| Links: | GitHub · Packagist |
Belongs To One Relation for Laravel 5.5
Based on Belongs To Many Relation. Returns one model instead of Collection of models.
Installation
composer require megapixel23/belongs-to-one
Usage
BelongsToOne relation is almost identical to standard BelongsToMany except it returns one model instead of Collection of models and null if there is no related model in DB (BelongsToMany returns empty Collection in this case). Include Megapixel23\Database\Eloquent\Relations\BelongsToOneTrait within your Model and use BelongsToOne relation.
Example:
<?php
namespace App\Models;
use App\Models\Group;
Use Illuminate\Database\Eloquent\Model;
use Megapixel23\Database\Eloquent\Relations\BelongsToOneTrait;
class Record extends Model
{
use BelongsToOneTrait;
public function group()
{
return $this->belongsToOne(Group::class);
}
}
And then use it like any other relation:
$record = Record::with('group')->first();
Testing
./vendor/bin/phpunit
Alternatives to megapixel23/belongs-to-one
Version History
| Version | Released | Laravel | License |
|---|---|---|---|
| 2.0.0 | ^5.5 | MIT | |
| v1.0.0 | ^5.3 | MIT |