I have Magento 2.3. I created Status.php
in Banner/Slider/Model/Slider/Source
but it gives an error
Invalid argument supplied for foreach() in
C:\xampp\htdocs\mag3\app\code\Banner\Slider\Model\Slider\Source\Status.php on line 22
this is Status.php
<?php
namespace Banner\Slider\Model\Slider\Source;
use Banner\Slider\Model\Slider;
use Magento\Framework\Data\OptionSourceInterface;
class Status implements OptionSourceInterface
{
protected $status_slider;
public function __construct(Slider $status_slider)
{
$this->status_slider = $status_slider;
}
public function toOptionArray()
{
$availableOptions = $this->status_slider->getAvailableStatuses();
$options = [];
foreach ($availableOptions as $key => $value) {
$options[] = [
'label' => $value,
'value' => $key,
];
}
return $options;
}
}