cmandersen/has-one-specific

Add a Laravel relationship where you can specify a set ID, instead of a dynamic relationship

Maintainers

Package info

github.com/cmandersen/has-one-specific

pkg:composer/cmandersen/has-one-specific

Statistics

Installs: 8 180

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2025-05-09 09:23 UTC

This package is auto-updated.

Last update: 2026-03-09 10:59:54 UTC


README

Add a Laravel relationship where you can specify a set ID, instead of a dynamic relationship

Installation

composer require cmandersen/has-one-specific

Usage

This package is basically just a trait that uses a relationship class, so it's just a case of using the trait where you need it.

class User extends Model {
    use \CMAndersen\HasOneSpecific\HasOneSpecific;
    
    public function company(){
        return $this->hasOneSpecific(Company::class, 97);
    }
}