Comments (12)
There is an issue you should fix: Both attribute and relationship are named parameters
. This is problematic because it prevents you from accessing the relationship with $vacancy->parameters
.
from eloquent-json-relations.
What query are you executing to get this result? What are the JobVacancy
's attributes?
from eloquent-json-relations.
What query are you executing to get this result? What are the
JobVacancy
's attributes?
JobVacancy
's attributes:
protected $fillable = [
'price',
'price_end',
'shortcuts',
'parameter_heading_id',
'parameter_location_id',
'parameters',
'status',
'archive',
];
protected $casts = [
'price' => 'float',
'price_end' => 'float',
'shortcuts' => 'array',
'parameter_heading_id' => 'integer',
'parameter_location_id' => 'integer',
'archive' => 'integer',
'parameters' => 'json',
'status' => 'integer',
];
query method
/**
* GetModelsForPublic.
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getModelsForPublic()
{
$query = $this->model::query();
$query->searchVacancy();
$query->sortVacancy();
$query->with('parameters');
return $query->where('status', true)
->paginate(8);
}
dump
$vacancies = $this->job_vacancy_repository->getModelsForPublic();
dd($vacancies->first());
from eloquent-json-relations.
What's the result of dd($vacancies->first()->getAttributes());
?
from eloquent-json-relations.
What's the result of
dd($vacancies->first()->getAttributes());
?
array:12 [▼
"id" => 1
"price" => 50.0
"price_end" => 50.0
"shortcuts" => "[{"value":1}]"
"parameter_heading_id" => 3
"parameter_location_id" => 17
"parameters" => "[{"id":17},{"id":22},{"id":13},{"id":9},{"id":6}]"
"status" => 1
"created_at" => "2020-05-08 11:46:00"
"updated_at" => "2020-05-15 22:07:42"
"sorting_order" => 999
"archive" => 0
]
from eloquent-json-relations.
Thanks, I'll look into it.
from eloquent-json-relations.
What's the result of
dd($vacancies->first()->getAttributes());
?
Laravel Framework 6.18.14
"require": {
"php": "^7.2",
"ext-gd": "*",
"ext-json": "*",
"artesaos/seotools": "^0.17.2",
"astrotomic/laravel-translatable": "^11.7",
"fideloper/proxy": "^4.0",
"fruitcake/laravel-cors": "2.0.x-dev",
"itsgoingd/clockwork": "^4.0",
"jenssegers/agent": "^2.6",
"kalnoy/nestedset": "^5.0",
"laravel/framework": "^6.2",
"laravel/tinker": "^2.0",
"mcamara/laravel-localization": "^1.5",
"pherum/laravel-bbcode": "^1.0",
"prettus/l5-repository": "^2.6",
"staudenmeir/eloquent-json-relations": "^1.1",
"tymon/jwt-auth": "^1.0.0-rc.5"
},
The Parameter class has trait NodeTrait, but it is also impossible to get data without it. The only thing that changes after I remove this trait
before
"parameters" => Kalnoy\Nestedset\Collection {#1815 ▼
#items: []
}
after
"parameters" => Illuminate\Database\Eloquent\Collection {#1809 ▼
#items: []
}
from eloquent-json-relations.
Thanks, I'll look into it.
Okay, thanks.
from eloquent-json-relations.
I haven't been able to reproduce the issue so far.
Can you log the executed queries with \DB::enableQueryLog(); [...] dd(\DB::getQueryLog());
or a package like https://github.com/barryvdh/laravel-debugbar?
from eloquent-json-relations.
There is an issue you should fix: Both attribute and relationship are named
parameters
. This is problematic because it prevents you from accessing the relationship with$vacancy->parameters
.
Aww... I hadn't thought of that. My apologies. I'll check later, because I probably won't be working today.
from eloquent-json-relations.
There is an issue you should fix: Both attribute and relationship are named
parameters
. This is problematic because it prevents you from accessing the relationship with$vacancy->parameters
.
Good time of day. I found a problem that caused the package to not work. Despite the fact that the data was correct after the selection in the collection the model had mutations that I removed and everything started working. I'm sorry to have disturbed you.
But the name will need to be changed in any case, as it is misleading.
from eloquent-json-relations.
No worries, I'm glad you could solve it.
from eloquent-json-relations.
Related Issues (20)
- pivot always return the same data on belongsToJson HOT 3
- Support for filtering by pivot value? HOT 5
- Support for custom key HOT 1
- BelongsToJson returns wrong results HOT 2
- hasMany - belongsToJson - hasManyJson HOT 4
- Artisan model:show failed HOT 1
- Need a basic Understanding for a json_encoded column HOT 6
- getAttribute() conflict HOT 1
- SqliteGrammar / Sqlite support HOT 11
- laravel compoships HOT 4
- Defining Json Relation in factory definition HOT 3
- Not an issue, really need a help HOT 2
- Nested Array of Objects throws array_key_exists(): Argument #2 ($array) must be of type array, null given HOT 2
- has and WhereHas doesn't work HOT 1
- One dimensional array HOT 5
- MySQL MEMBER OF () performance improvements HOT 5
- Is it possible to define a relationship using a key that can be nested at variable depths? HOT 14
- Great Package HOT 1
- String values fail for belongsToJson and HasManyJson HOT 4
- Many To Many Eager Loading Breaks with array_key_exists(): Argument #2 ($array) must be of type array, null given HOT 5
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 eloquent-json-relations.