Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Kodeine/Acl/Models/Eloquent/Permission.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace Kodeine\Acl\Models\Eloquent;

use Illuminate\Database\Eloquent\Model;
use Exception;

class Permission extends Model
{
Expand Down Expand Up @@ -51,6 +52,8 @@ public function getSlugAttribute($value)

/**
* @param $value
*
* @throws Exception
*/
public function setSlugAttribute($value)
{
Expand All @@ -74,7 +77,12 @@ public function setSlugAttribute($value)
$value = array_filter($value, 'is_bool');

// store as json.
$this->attributes['slug'] = json_encode($value);
$json = json_encode($value);
if (strlen($json) > 1024) {
throw new Exception('Slug max length (1024) is exceeded. Consider reducing amount ' .
'of slug items and/or move them into different permission.');
}
$this->attributes['slug'] = $json;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function up()
$table->integer('inherit_id')->unsigned()->nullable()->index();
$table->foreign('inherit_id')->references('id')->on('permissions');
$table->string('name')->index();
$table->string('slug')->index();
$table->string('slug', 1024)->index();
$table->text('description')->nullable();
$table->timestamps();
});
Expand Down