Hello all
i need to create poll system on my web
i found some package its called public function
inani/larapoll - > https://github.com/akiyamaSM/larapoll
i installed package but i don't know how it works
controller
public function socialog()
{
$poll = new Poll([
'question' => 'What is the best PHP framework?'
]);
// attach options and how many options you can vote to
// more than 1 options will be considered as checkboxes
$poll->addOptions(['Laravel', 'Zend', 'Symfony', 'Cake'])
->maxSelection() // you can ignore it as well
->generate();
$poll->isRadio(); // true
$poll->isCheckable(); // false
$poll->optionsNumber(); // 4
return view('pages/socialog/socialog')
->with('socialog');
}
on blade
{{ PollWriter::draw(Poll) }}
buts its errors me telling that addOptions needed so i created models Poll and PollOption
Poll
public function addOptions()
{
return $this->hasMany(PollOption::class, 'poll_id', 'id');
}
}
PollOption
public function addOptions()
{
return $this->belongsTo(Poll::class, 'poll_id', 'id');
}
now its errors ' Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::maxSelection() '
if its full package why i must create models ?
i think i'm doing something wrong ( can anyone please help me : )