2017 © Pedro Peláez
 

library belongs-to-one

Belongs To One Laravel 5 Relation class

image

megapixel23/belongs-to-one

Belongs To One Laravel 5 Relation class

  • Saturday, December 16, 2017
  • by MEGApixel23
  • Repository
  • 2 Watchers
  • 3 Stars
  • 593 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

Belongs To One Relation for Laravel 5.5

Travis CI, (*1)

Based on Belongs To Many Relation. Returns one model instead of Collection of models., (*2)

Installation

composer require megapixel23/belongs-to-one, (*3)

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., (*4)

Example:, (*5)

<?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:, (*6)

$record = Record::with('group')->first();

Testing

./vendor/bin/phpunit, (*7)

The Versions

16/12 2017

dev-master

9999999-dev

Belongs To One Laravel 5 Relation class

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar MEGApixel23

orm database laravel laravel-5 relation

16/12 2017

2.0.0

2.0.0.0

Belongs To One Laravel 5 Relation class

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar MEGApixel23

orm database laravel laravel-5 relation

13/05 2017

v1.0.0

1.0.0.0

Belongs To One Laravel 5 Relation class

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar MEGApixel23

orm database laravel laravel-5 relation

12/05 2017

dev-testing

dev-testing

Belongs To One Laravel 5 Relation class

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar MEGApixel23

orm database laravel laravel-5 relation