laracraft-tech / laravel-dynamic-model Goto Github PK
View Code? Open in Web Editor NEWDynamic Eloquent models for Laravel
License: MIT License
Dynamic Eloquent models for Laravel
License: MIT License
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
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 :)
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?
Hi, I tried to install to Laravel 10.0 it is not allow. Please update composer if it is workable
Super handy code. Thanks for your hard work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.