i updated laravel version from 5.6 to 6 one week ago for implementing new things on my API, problem is after the update one of my relations just broke. At certain point after login i need to retrieve some info based on who is connected, on a 3 level relation (cme_permissions.subcomisionData.members) and it brokes on second level (cme_permissions.subcomisionData), i looked at this using dd() step by step. I'm just starting into this world of programming and i don't know what the heck is happening, thanks for the help.
Query:
User::where('id', Auth::user()->id)
->with('cme_permissions.subcomisionData.members')->get();
First relation (User):
public function cme_permissions() {
return $this->hasMany('App\CME\CMEPermission');
}
Second relation:
class CMEPermission extends Model
{
public $table = 'cme_permissions';
public function subcomisionData() {
return $this->belongsTo('App\CME\CMESubcomision', 'subcomision');
}
function user() {
return $this->belongsTo('App\User');
}
}
Third relation:
class CMESubcomision extends Model
{
public $table = 'cme_subcomision';
public $incrementing = false;
public $timestamps = false;
public function members() {
return $this->hasMany('App\CME\CMEPermission', 'subcomision')
->with('user');
}
}
This still works on my pre-version before the update so i don't know if the problem is with the dependencies in composer.json or what, whatever here it is: Composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "6.0.*",
"laravel/passport": "^7.1",
"laravel/tinker": "^1.0",
"league/csv": "^9.5",
"elibyy/tcpdf-laravel": "6.0.*"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.6",
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
Edit: It doesn't display any error just a null on the second relation
#relations: array:1 [
"cme_permissions" => Illuminate\Database\Eloquent\Collection {#469
#items: array:1 [
0 => App\CME\CMEPermission {#466
+table: "cme_permissions"
#connection: "mysql"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:5 [
"id" => 2
"user_id" => 1685
"email" => "[email protected]"
"subcomision" => "1.1"
"cme_role" => "Vocal"
]
#original: array:5 [
"id" => 2
"user_id" => 1685
"email" => "[email protected]"
"subcomision" => "1.1"
"cme_role" => "Vocal"
]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: array:1 [
"subcomisionData" => null
]
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL.
It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/
Foundation, similar to Bootstrap, has become very popular as a more complex framework with some advanced but easy-to-implement CSS components. It is built with Sass, so just like Bootstrap, it is customizable. In addition to this, it also boasts some features that help make the design mobile responsive.
https://get.foundation/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.