hi guys i'm using jessengers mongodb extension , i've have mongodb populate , problem is showing guarded attributes , code is:
model:
<?php namespace app; use jenssegers\mongodb\model eloquent; use \jenssegers\mongodb\eloquent\softdeletes; class pessoas extends eloquent { public $guarded = ['password']; public $fillable = ['nome']; }
router
route::get('/pessoas', function () { $pessoas = \app\pessoas::all(); dd($pessoas); });
return
0 => pessoas {#147 ▼ +guarded: array:1 [▶] **<<<< 1 guarded** +fillable: array:1 [▶] **<<<<<< 1 fillable** #collection: null #primarykey: "_id" #parentrelation: null #connection: null #table: null #perpage: 15 +incrementing: true +timestamps: true #attributes: array:27 [▶] **<<<<<<< 1 expected or 26** #original: array:27 [▶] **<<<<<< ok** #relations: [] #hidden: [] #visible: [] #appends: [] #dates: [] #dateformat: null #casts: [] #touches: [] #observables: [] #with: [] #morphclass: null +exists: true +wasrecentlycreated: false }
a query using jessengers mongodb extension returns collection
object. since you're dumping values of object, see protected , public properties of object. prevent should use toarray()
method on collection
object.
route::get('/pessoas', function () { $pessoas = \app\pessoas::all(); dd($pessoas->toarray()); });
Comments
Post a Comment