Comments (8)
Are you using this with Laravel?
The reason i ask, is that save() should not duplicate. Once the model has been saved once, it will be given an ID, and will then update instead of inserting from then on. Or at least it should
from factory-muffin.
body p { margin-bottom: 0cm; margin-top: 0pt; }
Yes I am using it with Laravel.On 6/19/2014 1:28 PM, Scott Robertson
wrote:
Are you using this with Laravel?
The reason i ask, is that save() should not duplicate. Once the
model has been saved once, it will be given an ID, and will then
update instead of inserting from then on. Or at least it should
—
Reply to this email directly or view
it on GitHub.
--
David Suna
[email protected]
from factory-muffin.
Hmm maybe they return false if you have no changed anything in the model since the last save.
from factory-muffin.
body p { margin-bottom: 0cm; margin-top: 0pt; }
I stepped through it in the debugger and it was failing on the
validations for unique columns.On 6/19/2014 1:30 PM, Scott Robertson
wrote:
Hmm maybe they return false if you have no changed anything in
the model since the last save.
—
Reply to this email directly or view
it on GitHub.
--
David Suna
[email protected]
from factory-muffin.
How very odd, not sure why it would try and save it as a new row.
from factory-muffin.
Here is a stripped down version of my model. The validation is run before attempting to save to the database. If I remove the unique:phone_models from the rules then it is OK. This is a known problem with using save with unique validation. Ardent has a special method (updateUniques) which addresses this problem but the example code uses save. I worked around this problem by using instance instead of create on the factory.
<?php
use LaravelBook\Ardent\Ardent;
class PhoneModel extends Ardent {
/**
* List of fields that can be automatically filled in from form
data
* @var array
*/
protected $fillable = array("name", "description", "notes");
/**
* Validation Rules
* @var array
*/
public static $rules = array(
'name' =>
'required|unique:phone_models|alpha_num|between:4,16',
'description' => 'required'
);
/**
* Rules for FactoryMuff to be able to generate arbitrary entries
* @var array
*/
public static $factory = array(
'name' => 'string',
'description' => 'string',
'notes' => 'string',
);
/**
* hydrates on new entries' validation
* @var boolean
*/
public $autoHydrateEntityFromInput = true;
/**
* hydrates whenever validation is called
* @var boolean
*/
public $forceEntityHydrationFromInput = true;
/**
* The database table used by the model.
* @var string
*/
protected $table = 'phone_models';
}On 6/19/2014 1:35 PM, Scott Robertson
wrote:
How very odd, not sure why it would try and save it as a new
row.
—
Reply to this email directly or view
it on GitHub.
--
David Suna
[email protected]
from factory-muffin.
I had the same issue - sort of #36.
from factory-muffin.
I believe this is not really a bug in our library. We are just returning what ever Laravel returns. They are having a debate as to what ->save() should be returning.
from factory-muffin.
Related Issues (20)
- PHPUnit 6.0 support HOT 2
- Question: "The model class is undefined." error. HOT 3
- what is '$fm' ? HOT 1
- Question: Is there any way to create a doctrine entity without a need for setters?
- Update documentation on the league website to match the README on the ~3.0 branch HOT 8
- What is `$fm` in the factory definitions? HOT 2
- Make the error message in DeletingFailedException more descriptive HOT 2
- OneToMany Doctrine relation.
- Factory Muffin converts false values to empty strings HOT 1
- Allow write to private properties and/or create instance without constructor calling HOT 1
- No explicit support by FactoryGenerator HOT 2
- still maintained? HOT 2
- How to place an Auto-increment id in v3.1 HOT 1
- FM tries to call string as a function if its the same name as a built-in HOT 2
- Custom Maker is gone in v3 HOT 5
- Add warning to docs that you can't use your own Faker instance HOT 3
- Add warning to docs that you can't use your own Faker instance HOT 9
- Callbacks don't stack
- Does Factory Muffin supports multiple entity managers?
- Unresolved composer.json requirements when action according contribution guideline HOT 1
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 factory-muffin.