1

I have an admin panel which enables admins to assign different permissions to a user. The way that I do this is through tick boxes and when ticked it should assign a 1 to that permission.

The only problem is, the permissions are dynamic and so needs to go through a loop. I've had some trouble trying to grasp how I would got about assigning permissions this way as in my guess needs to loop through an array and then place the values into another array.

Does anyone know how I would go about this?

I have tried things like...

$park = Input::get('parks');
$permissions = array();

for($i = 0; $i < count($park); $i++)
{
    $permissions = $park[$i] => 1;
}

Or...

$park = Input::get('parks');

for($i = 0; $i < count($park); $i++)
{
    $park[$i] => 1;
}

Obviously the first one comes up with errors, but the second one will just come out as [1,1,1,1] .

Any help would be appreciated.

JamesHalsall
  • 13,224
  • 4
  • 41
  • 66
CheckeredMichael
  • 571
  • 8
  • 30
  • "*the second one will just come out as [1,1,1,1].*" — Obviously. What do you want it to do output instead? – Amal Murali May 16 '14 at 12:59
  • In Sentry the permissions need to look like this... {1:1,2:1} or {"1":1,"2":1} within the database. – CheckeredMichael May 16 '14 at 13:08
  • @CheckeredMichael, did you find the solution? I also want to create a dynamic permission through checkbox from admin panel. If you found the solution, then save me. – Tahsin Abrar Jan 08 '15 at 07:47

0 Answers0