GithubHelp home page GithubHelp logo

laracraft-tech / laravel-dynamic-model Goto Github PK

View Code? Open in Web Editor NEW
40.0 4.0 0.0 75 KB

Dynamic Eloquent models for Laravel

License: MIT License

PHP 100.00%
eloquent laravel model dynamic-model dynamic-schema dynamic-table php

laravel-dynamic-model's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar sairahcaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-dynamic-model's Issues

Defning belongsTo Relation in Dynamic Model

Hi
I have a dynamic model (dataInFile) which extends DynamicModel. This model has a reverse one-to-many relation with another model (UploadedFile).

class DataInFile extends DynamicModel
{
    use HasFactory;
    public function file(){
        return $this->belongsTo(UploadedFile::class);
    }
}

class UploadedLists extends Model
{
    use HasFactory;
    public function fileData(): HasMany
    {
        $foo = app(DynamicModelFactory::class)->create(DataInFile::class, 'data_1_1');
        return $this->hasMany($foo, 'fileId');
    }
}

When I access the DataInFile model with

 $foo = app(DynamicModelFactory::class)->create(DataInFile::class, 'data_1_1');
 $foo->find(1);

it works fine and I am able to get the uploadedFile.
However the reverse does not work, error being Base table or view not found: 1146 Table 'my_data_base.data_in_file' doesn't exist

So is there a way to be able to do this?

Also to make it a little more complicated the name of the table depends on a column in the table UploadedLists .

Is this something that can be achieved.

Any help is highly appreciated

Add connection to allow different database then default

It would be nice to add connection(table_connection?) as option to DynamicModel to allow use of a different database then the default one.
My dynamic tables are in a different table then the default to make it easier to separate them :)

Unable to use geography types

Hello, I'm using Postgresql with PostGIS enabled and have a table which contains a column of type geography.

Im getting this error below:

Doctrine\DBAL\Exception Unknown database type geography requested, Doctrine\DBAL\Platforms\PostgreSQL100Platform may not support it.

May I know if it's supported to use geography types or am I doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.