I have recently started learning Laravel and I'm trying to reference a static field, in this case $myUrls, in my Model's create method. This is what I'm trying to do but I keep getting the error:
Undefined variable: myUrls
class myclass extends mySuperclass
{
public static $myUrls= [ some data]
public static function create( array $attributes = [] )
{
$newObj = parent::create($attributes);
$newObj->buildUrlLookups($newObj);
return $newObj;
}
private function buildUrlLookups($newObj)
{
foreach ($newObj->$myUrls as $u)
{
//some code
}
}
I have also tried it with $this->myUrls and just $myUrls but non works.
try
foreach (self::$myUrls as $u)