Comments (5)
Same issue here. Instead of modifying the package I've overridden the newFormBuilder
method.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Nanigans\SingleTableInheritance\Exceptions\SingleTableInheritanceException;
use Nanigans\SingleTableInheritance\SingleTableInheritanceTrait;
class MyEloquentModel extends Model
{
use SingleTableInheritanceTrait {
newFromBuilder as private traitNewFromBuilder;
}
// ...
public function newFromBuilder($attributes = array(), $connection = null) {
try {
return $this->traitNewFromBuilder($attributes, $connection);
} catch (SingleTableInheritanceException $e) {
return parent::newFromBuilder($attributes, $connection);
}
}
}
from single-table-inheritance.
A failing test case in a pull request would be helpful to track this down.
from single-table-inheritance.
I ran into a similar issue when combining with the sluggable library trait. I ended up changing line 191:
throw new SingleTableInheritanceException("Cannot construct newFromBuilder without a value for $typeField");
To be:
return parent::newFromBuilder($attributes);
I guess on the assumption if you are dealing with a subset of fields you are probably not using full objects and base functionality is fine? I'm sure of the implications of doing this though, there are probably consequences
from single-table-inheritance.
I stuck with same issue and hoping next release will have the fix.
from single-table-inheritance.
Fixed.
from single-table-inheritance.
Related Issues (20)
- "Field 'type' doesn't have a default value" when saving a model HOT 3
- Update Readme HOT 1
- One record two types. HOT 3
- Can we set the type of model using the base model? HOT 5
- hasMany relation doesn't work for parent class
- Can't create a new record directly form the base class HOT 10
- Broken link in README - Mark Smith's website is gone HOT 1
- Laravel 5.7 Support HOT 6
- Type is not inserted when using Laravel factories HOT 1
- Travis Builds are failing HOT 2
- Laravel 5.8 support
- Support the Eloquent `retrieved` event HOT 1
- Cannot insert record HOT 6
- V0.8.6 causes incorrect attributes to be set HOT 11
- Laravel 6.0 support HOT 1
- Eager loading child model relationship HOT 2
- Enhence performance when querying root model of subclasses HOT 5
- PHP hangs when parent and child inheritance is not setted properly. HOT 3
- `newFromBuilder` does not maintain mutated attributes HOT 2
- onlyTrashed()->forceDelete() seems to lose the SingleTableInheritance scope, deletes way more than intended HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from single-table-inheritance.