ardent icon indicating copy to clipboard operation
ardent copied to clipboard

Fix backtrace index in belongsTo method

Open dangreaves opened this issue 9 years ago • 1 comments

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.

dangreaves avatar Apr 07 '16 03:04 dangreaves

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?

igorsantos07 avatar Oct 03 '18 14:10 igorsantos07