alıcı kısmı branches ve roles
branches ( bir kullanıcı birden fazla şubede yetkili olabiliyor) vt de ; ile ayırarak kaydedildi örnek ;5;6; branch_id 5(a şubesi) , 6(b şubesi) olan kullanıcılara, boş ise tüm şubelerdeki kullanıcılar için
roles (bir kullanıcının birden fazla rolü olabiliyor) ;17;21;22; (admin, müdür, md yardımcısı olan kullanıcılara) boş işe tüm kullanıcılara gibi
formda bu iki alan select2 multiple
<div class="form-group">
{!! Form::label('branches[]', trans_title('branch_id'),['class'=>'col-sm-3 control-label']) !!}
<div class="col-sm-8">
{!! Form::select('branches[]', $branchList, null, ['class' => 'form-control select2', 'style' => 'width: 100%', 'multiple']) !!}
</div>
</div>
Model
/**
* Get a list of branches
*
* @return array
*/
public function getBranchesAttribute($value)
{
return explode(';', $value);
}
/**
* Set the branches
*
* @param string $value
* @return void
*/
public function setBranchesAttribute($value)
{
$this->attributes['branches'] = $value ? ';'.implode(';', $value).';':'';
}
İyi çalışmalalar..