php - I received Using $this when not in object context error in Laravel
one text
I'm getting a Using $this when not in object context
error in my function which just needs to divide the current numbers by the current rate. My function code:
public function autoRanksCurrency ()
{
$ranks = Ranks::get();
foreach ($ranks as $rank) {
$bets = $rank->bets;
$deposit = $rank->deposit;
$reward = $rank->reward;
$bonus = $rank->bonus;
$update = Ranks::update([
'bets' => $rank->bets / $this->config->kurs
]);
$update->save();
}
}
$this->config
comes from my database.
Where can beaproblem?
i already try some variants, but nothing works.
UPD:
I make dd($this->config)
, and here is what i received:
App\Models\Config {#494 ?�?
#table: "config"
#fillable: array:10 [?��]
#connection: "mysql"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: array:49 [?��]
#original: array:49 [?��]
#changes: []
#casts: []
#classCastCache: []
#attributeCastCache: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#guarded: array:1 [?��]
}
How i understand, function understand $this->config
variable.