Giter Club home page Giter Club logo

Comments (8)

scottrobertson avatar scottrobertson commented on September 21, 2024

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.

edsuna avatar edsuna commented on September 21, 2024

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.

scottrobertson avatar scottrobertson commented on September 21, 2024

Hmm maybe they return false if you have no changed anything in the model since the last save.

from factory-muffin.

edsuna avatar edsuna commented on September 21, 2024

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.

scottrobertson avatar scottrobertson commented on September 21, 2024

How very odd, not sure why it would try and save it as a new row.

from factory-muffin.

edsuna avatar edsuna commented on September 21, 2024

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.

HVSoftware avatar HVSoftware commented on September 21, 2024

I had the same issue - sort of #36.

from factory-muffin.

scottrobertson avatar scottrobertson commented on September 21, 2024

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)

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.