I have a model with 2 functions. Let's say the model's name is Cars
. I am trying to call one function brand
that returns an array so I can use it inside the other getBrand
function.
public static function getBrand($data) {
$brandVariable = $this->brand();
for ($i=1; $i < count($brandVariable ) ; $i++) {
//do something
}
}
public static function brand() {
$arrayValues = array(
1 => 'Brand A',
2 => 'Brand B',
);
return arrayValues;
}
Since the values are in brand
function, I need to pass it inside getBrand
.
I am getting an error in the for
loop. I tried in another file (local PHP not Laravel) and it is working fine. But in Laravel, it is not getting the expected result.