Coder Social home page Coder Social logo

Comments (13)

duellsy avatar duellsy commented on June 27, 2024

This would be because the raw data is what is stored in the revisions table, hence the data that is output is simply

$revision->old_value

I'll have a look and see if there's a way to make it smarter, and output using the mutator if available

from revisionable.

mmodler avatar mmodler commented on June 27, 2024

According to the eloquent docs Accessors are named like this:

getFieldnameAttribute

You check for method getFieldname atm, so this can't work for me :)

from revisionable.

duellsy avatar duellsy commented on June 27, 2024

Oops... sorry. Fixed up, try that.

from revisionable.

mmodler avatar mmodler commented on June 27, 2024

And now also in line 140 - thats the problem with redundant code, as always ;)

from revisionable.

duellsy avatar duellsy commented on June 27, 2024

true

from revisionable.

mmodler avatar mmodler commented on June 27, 2024

Now the accessor is used. Good! But the main model attributes are not there:

 public function getPriceAttribute() {
    return str_replace('.', ',', $this->attributes['price']);
}

Undefined index: price

from revisionable.

duellsy avatar duellsy commented on June 27, 2024

Where are you calling the set method from?

Sent from iPhone

On Wed, Aug 7, 2013 at 10:36 PM, mmodler [email protected] wrote:

Now the accessor is used. Good! But the main model attributes are not there:

public function setPriceAttribute($price) {
    $this->attributes['price'] = str_replace(',', '.', $price);
}```
Undefined index: price
---
Reply to this email directly or view it on GitHub:
https://github.com/VentureCraft/revisionable/issues/21#issuecomment-22247733

from revisionable.

mmodler avatar mmodler commented on June 27, 2024

It happens in my Revision detail controller with

$revision = Revision::find(Input::get('revision_id', null))

from revisionable.

duellsy avatar duellsy commented on June 27, 2024

Not sure why that would call the set mutator. Don't suppose you have a full stack trace?

Sent from iPhone

On Wed, Aug 7, 2013 at 10:42 PM, mmodler [email protected] wrote:

It happens in my Revision detail controller with

$revision = Revision::find(Input::get('revision_id', null))

Reply to this email directly or view it on GitHub:
#21 (comment)

from revisionable.

mmodler avatar mmodler commented on June 27, 2024

It really should! If i load a single revision i also want to have nice "mutated" data.

Stack trace:

ErrorException
…/­app/­models/­Seminardate.php34
Illuminate\Exception\Handler handleError
…/­app/­models/­Seminardate.php34
App\Models\Seminardate getPriceAttribute
…/­vendor/­venturecraft/­revisionable/­src/­Venturecraft/­Revisionable/­Revision.php142
Venturecraft\Revisionable\Revision getValue
…/­vendor/­venturecraft/­revisionable/­src/­Venturecraft/­Revisionable/­Revision.php61
Venturecraft\Revisionable\Revision oldValue
…/­app/­controllers/­admin/­RevisionsController.php20
App\Controllers\Admin\RevisionsController getRevisionJson
<#unknown>0
call_user_func_array
…/­vendor/­laravel/­framework/­src/­Illuminate/­Routing/­Controllers/­Controller.php138
Illuminate\Routing\Controllers\Controller callMethod
…/­vendor/­laravel/­framework/­src/­Illuminate/­Routing/­Controllers/­Controller.php115
Illuminate\Routing\Controllers\Controller callAction
…/­vendor/­laravel/­framework/­src/­Illuminate/­Routing/­Router.php985
Illuminate\Routing{closure}
<#unknown>0
call_user_func_array
…/­vendor/­laravel/­framework/­src/­Illuminate/­Routing/­Route.php80
Illuminate\Routing\Route callCallable
…/­vendor/­laravel/­framework/­src/­Illuminate/­Routing/­Route.php47
Illuminate\Routing\Route run
…/­vendor/­laravel/­framework/­src/­Illuminate/­Routing/­Router.php1016
Illuminate\Routing\Router dispatch
…/­vendor/­laravel/­framework/­src/­Illuminate/­Foundation/­Application.php522
Illuminate\Foundation\Application dispatch
…/­vendor/­laravel/­framework/­src/­Illuminate/­Foundation/­Application.php497
Illuminate\Foundation\Application run
…/­public/­index.php49

from revisionable.

mmodler avatar mmodler commented on June 27, 2024

Stop thinking! ;) It was my fault. With accessors i should use getFieldnameAttribute($value) and work with $value, not with $this...

from revisionable.

duellsy avatar duellsy commented on June 27, 2024

What is the line of code that is causing the problem?

Revisionable doesn't call any setSomeAttribute() mutators, it only calls the getSomeAttribute() accessor

Your stack trace looks like it's calling the getPriceAttribute accessor, but there's no reference to the setPriceAttribute being called... or am I missing something?

from revisionable.

duellsy avatar duellsy commented on June 27, 2024

Ahhh, awesome. All sorted then.

from revisionable.

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.