Comments (18)
Yup, Former uses the __toString
method of a model to render it in a list, unless you specify otherwise (like here with username
). Somehow it got highjacked and used the default output for models in Laravel 4 (json).
I'll check it out.
EDIT : Apparently the username
can be bypassed if the isset fails. You sure there's an username
method or attribute ? (stupid question but you never know)
from former.
Ah ok, nice to learn more about how it does things, I find it much easier to use if I really know what it's doing! :) Thanks very much
from former.
...but it's still broken or ?
from former.
Yeah, still broken! The fact that I like to know what's going on is totally unrelated really lol
from former.
Did you check there was an username attribute or method on your returned models ?
from former.
It's right there in the JSON output, as is the id :)
from former.
Ah fuck, yeah, didn't even notice. Well that's just weird.Maybe Former doesn't like the new Eloquent Collections, will write a test for it see if it fails.
from former.
Just pushed a change, can you try again ?
from former.
Notice: Undefined variable: app in /Applications/MAMP/Web/Sites/LearnLaravel/vendor/anahkiasen/former/src/Former/FormerServiceProvider.php line 48
from former.
I'm a moron. Try again.
from former.
Lol, you fixed that one, but I still get JSON
from former.
Ok I'm gonna setup a fresh app and try to reproduce it.
from former.
If it helps, here is a var_dump off the Eloquent collection:
object(Illuminate\Database\Eloquent\Collection)#165 (2) { ["items":protected]=> array(1) { [0]=> object(User)#158 (14) { ["table":protected]=> string(5) "users" ["hidden":protected]=> array(2) { [0]=> string(8) "password" [1]=> string(10) "auth_level" } ["connection":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(7) { ["id"]=> string(1) "1" ["username"]=> string(5) "admin" ["password"]=> string(60) "$2a$08$mz9ZA7etUBTj4KcRgVZ3RO4nsph6lfavBqQpQYqOg2yiE5zz1bFMu" ["name"]=> string(5) "Admin" ["created_at"]=> string(19) "0000-00-00 00:00:00" ["updated_at"]=> string(19) "0000-00-00 00:00:00" ["auth_level"]=> string(3) "100" } ["original":protected]=> array(7) { ["id"]=> string(1) "1" ["username"]=> string(5) "admin" ["password"]=> string(60) "$2a$08$mz9ZA7etUBTj4KcRgVZ3RO4nsph6lfavBqQpQYqOg2yiE5zz1bFMu" ["name"]=> string(5) "Admin" ["created_at"]=> string(19) "0000-00-00 00:00:00" ["updated_at"]=> string(19) "0000-00-00 00:00:00" ["auth_level"]=> string(3) "100" } ["relations":protected]=> array(0) { } ["fillable":protected]=> array(0) { } ["guarded":protected]=> array(0) { } ["dates":protected]=> array(0) { } ["exists"]=> bool(true) } } ["dictionary":protected]=> array(0) { } }
["items":protected] and ["dictionary":protected], the 2 top level arrays, are being pulled out of that and made into 's, which are then populated with their contents.
["items":protected]=> array(1) { [0]=> object(User)#158 (14) ......
["dictionary":protected]=> array(0)
from former.
SO, apparently instanceof
doesn't like when you don't use the full namespace. Which is kind of logical actually. Should work now.
from former.
Ah, awesome :)
from former.
All works perfectly, thanks very much :)
from former.
No problem :)
I redid my tests so that the working of Former didn't depend of how dependencies were working, problem is now I'm never sure the tests actually reflect how Former works in real life. Guess it's a trade-off.
from former.
Yeah, the only real solution is two sets of tests, but that's rather a lot more work!
from former.
Related Issues (20)
- Allow field->required() to receive a boolean HOT 1
- Allow field->inline() to receive a boolean HOT 2
- Add a Choice field type HOT 4
- Laravel 5.7 support HOT 1
- Support Bootstrap4 HOT 1
- Former Twitter Bootstrap 4 Not working HOT 2
- Custom Rule classes not working HOT 1
- Bootstrap 4 Framework uses wrong classes for input group & no classes for checkbox HOT 8
- Can Former be used outside/without Laravel? HOT 2
- Multiple attributes treated differently from single attribute in queryToArray
- Form echo like a text Laravel 5.7
- Encode checkbox value to prevent XSS attack HOT 1
- Bootstrap 4 throws error without open and close tag HOT 2
- How to style checkboxes HOT 6
- Laravel 8 support. HOT 1
- How to use vuejs directives with former HOT 2
- Former::date help HOT 1
- _method HOT 2
- How to use as a standalone PHP HOT 3
- Doesn't work on PHP8+ for standalone (non-laravel) apps 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 former.