Comments (13)
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.
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.
Oops... sorry. Fixed up, try that.
from revisionable.
And now also in line 140 - thats the problem with redundant code, as always ;)
from revisionable.
true
from revisionable.
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.
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.
It happens in my Revision detail controller with
$revision = Revision::find(Input::get('revision_id', null))
from revisionable.
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.
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.
Stop thinking! ;) It was my fault. With accessors i should use getFieldnameAttribute($value) and work with $value, not with $this...
from revisionable.
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.
Ahhh, awesome. All sorted then.
from revisionable.
Related Issues (20)
- identifiableName() doesnt work with model User HOT 1
- additional fields not beeing stored when Storing Creations HOT 2
- Supporting multiple auth HOT 1
- Nothing happens when I try to save instance from `Comment` model HOT 2
- Explicitly providing `user_id` to Revisionable HOT 1
- Revisionable not creating revision entries for belongsToMany relationships HOT 1
- Revisionable is largely abandonware – look elsewhere HOT 3
- More documentation around identifiableName() HOT 2
- so i created this fuction to return 'meta', anyone knows how to access [key] => date_achat / i want to display only the arrays where key == date_achat
- DateTime object to json serialization
- The article link in Readme.md is not working
- use in tables without integer primary key
- New Feature: Save changed and append custom data HOT 3
- Laravel 10 Support
- Is it a part instead of the whole? HOT 1
- Consider storing only attributes that have been changed and only the diff values HOT 1
- Please allow table name to be configurable HOT 2
- Invalid foreign key for SoftDelete returns unknown instead of the original id HOT 1
- Display revisions in Laravel Nova HOT 2
- Encrypted values not decrypting on read
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 revisionable.