All Projects → akiyamaSM → LazyBelongsToMany

akiyamaSM / LazyBelongsToMany

Licence: other
A lightweight implementation of Laravel's belongs To many

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to LazyBelongsToMany

laravel-attribute-observer
Observe (and react to) attribute changes made on Eloquent models.
Stars: ✭ 59 (+156.52%)
Mutual labels:  eloquent
encryptable
Laravel package for persisting encrypted Model properties, providing decryption when accessed.
Stars: ✭ 26 (+13.04%)
Mutual labels:  eloquent
php-orm-benchmark
The benchmark to compare performance of PHP ORM solutions.
Stars: ✭ 82 (+256.52%)
Mutual labels:  eloquent
laravel-quasar
⏰📊✨Laravel Time Series - Provides an API to create and maintain data projections (statistics, aggregates, etc.) from your Eloquent models, and convert them to time series.
Stars: ✭ 78 (+239.13%)
Mutual labels:  eloquent
plug
A collection of pluggable traits for Eloquent (Laravel) models
Stars: ✭ 13 (-43.48%)
Mutual labels:  eloquent
eloquent-filter
Library to form search criteria through expressions in the query string
Stars: ✭ 23 (+0%)
Mutual labels:  eloquent
eloquence
Eloquence provides a cache on top of Eloquent that prevents multiple models being created for a single database row using the Identity Map design pattern.
Stars: ✭ 18 (-21.74%)
Mutual labels:  eloquent
laravel-scoped-cache
Easily cache items specific to your Eloquent models without having to append the ID.
Stars: ✭ 28 (+21.74%)
Mutual labels:  eloquent
slim-boilerplate
A PHP boilerplate,for a fast API prototyping based on Slim Framework, for start projects with Eloquent ORM, Validation, Auth (JWT), Repositories and Transformers ready
Stars: ✭ 58 (+152.17%)
Mutual labels:  eloquent
laravel-cachable-attributes
Allows to cache attribute accessor values in an easy way.
Stars: ✭ 24 (+4.35%)
Mutual labels:  eloquent
inertiajs-tables-laravel-query-builder
Inertia.js Tables for Laravel Query Builder
Stars: ✭ 391 (+1600%)
Mutual labels:  eloquent
laravel-simplegrid
A simple component for generating powerful grids with Laravel.
Stars: ✭ 35 (+52.17%)
Mutual labels:  eloquent
acorn-db
Provides Acorn projects with Eloquent Models for WordPress data.
Stars: ✭ 30 (+30.43%)
Mutual labels:  eloquent
laratools
A collection of useful everyday tools for Laravel
Stars: ✭ 17 (-26.09%)
Mutual labels:  eloquent
laravel-sybase
Connection and Laravel Eloquent driver for Sybase
Stars: ✭ 29 (+26.09%)
Mutual labels:  eloquent
laravel-nestedupdater
Package for allowing updating of nested Eloquent model relations using a single nested data array.
Stars: ✭ 19 (-17.39%)
Mutual labels:  eloquent
laravel-query-inspector
The missing laravel helper that allows you to inspect your eloquent queries with it's bind parameters
Stars: ✭ 59 (+156.52%)
Mutual labels:  eloquent
query-filter
🔍 Database/Eloquent Query Builder filters for Laravel
Stars: ✭ 69 (+200%)
Mutual labels:  eloquent
eloquent-hashids
Automatically generate and persist Hashids for newly created Eloquent models.
Stars: ✭ 17 (-26.09%)
Mutual labels:  eloquent
state-machine
The hyn state machine package is a flexible library that helps you move Eloquent models from States through Transitions while emitting events along the way.
Stars: ✭ 14 (-39.13%)
Mutual labels:  eloquent

LazyBelongsToMany

A lightweight implementation of Laravel's belongs To many relationship in cases you don't need pivot table.

Installation

First, install the package through Composer.

composer require inani/lazy-belongs-to-many

Usage

Suppose we have the following database structure. A User can be linked to one or many Tag. instead of creating the pivot table we can save tags id list in a column on the user table.

| id | name              | tags_id       |
|----|-------------------|---------------|
| 1  | El Houssain inani | [1, 10, 4, 33]|
<?php

namespace Models;

use Illuminate\Database\Eloquent\Model;
use Inani\LazyBelongsToMany\Relations\BelongsToManyCreator;

class User extends Model
{
    use BelongsToManyCreator;
    
    protected $casts = [
      'tags_id' => 'array' // <=== IMPORTANT
    ];
    
    
    /**
    * Tags
     * @return mixed
    */
    public function tags()
    {
        return $this->belongsToManyInArray(Tag::class);
    }
}

For the time being there is no implementation for the inverse. I'll be happy to see your contribution at any way.

Happy Coding.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].