ardent
ardent copied to clipboard
Fix backtrace index in belongsTo method
Under certain conditions, it seems that the backtrace index for the belongsTo() method is incorrect. Under a broken condition, my backtrace looks like below.
array:4 [
0 => array:6 [
"file" => "/home/vagrant/projects/foobar/app/Models/Asset.php"
"line" => 26
"function" => "belongsTo"
"class" => "LaravelArdent\Ardent\Ardent"
"type" => "->"
"args" => array:1 [
0 => "App\Models\Account"
]
]
1 => array:6 [
"file" => "/home/vagrant/projects/foobar/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php"
"line" => 2690
"function" => "account"
"class" => "App\Models\Asset"
"type" => "->"
"args" => []
]
2 => array:6 [
"file" => "/home/vagrant/projects/foobar/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php"
"line" => 2663
"function" => "getRelationshipFromMethod"
"class" => "Illuminate\Database\Eloquent\Model"
"type" => "->"
"args" => array:1 [
0 => "account"
]
]
3 => array:6 [
"file" => "/home/vagrant/projects/foobar/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php"
"line" => 2605
"function" => "getRelationValue"
"class" => "Illuminate\Database\Eloquent\Model"
"type" => "->"
"args" => array:1 [
0 => "account"
]
]
]
Ardent is currently looking at index 3 which gives "getRelationValue" as the relation name. This beaks the belongsTo as the relation name should be "account".
I notice that in the latest Eloquent model, they are looking up index 1 in the backtrace array.
Is this still a thing? Would it be possible to check if in older Laravel versions the correct index was indeed 3, and it changed to 1 after a Laravel update?