Skip to content

Commit

Permalink
Merge pull request #5 from updivision/dev
Browse files Browse the repository at this point in the history
v1.1 Beta
  • Loading branch information
Paul Duca authored Jan 25, 2018
2 parents bbdb8b3 + bb7c3bb commit 14bf810
Show file tree
Hide file tree
Showing 126 changed files with 8,392 additions and 879 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

ADMIN_ROLE_NAME=administrator
CLIENT_ROLE_NAME=client
45 changes: 36 additions & 9 deletions app/Http/Controllers/Admin/AttributeCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public function setUp()
]
]);

/*
|--------------------------------------------------------------------------
| PERMISSIONS
|-------------------------------------------------------------------------
*/
$this->setPermissions();

/*
|--------------------------------------------------------------------------
| FIELDS
Expand All @@ -52,18 +59,39 @@ public function setUp()
*/
$this->crud->enableAjaxTable();

/*
|--------------------------------------------------------------------------
| ACCESS
|--------------------------------------------------------------------------
*/
// $this->crud->denyAccess(['delete']);
//
}

public function setFields()
public function setPermissions()
{
// Get authenticated user
$user = auth()->user();

// Deny all accesses
$this->crud->denyAccess(['list', 'create', 'update', 'delete']);

// Allow list access
if ($user->can('list_attributes')) {
$this->crud->allowAccess('list');
}

// Allow create access
if ($user->can('create_attribute')) {
$this->crud->allowAccess('create');
}

// Allow update access
if ($user->can('update_attribute')) {
$this->crud->allowAccess('update');
}

// Allow delete access
if ($user->can('delete_attribute')) {
$this->crud->allowAccess('delete');
}
}

public function setFields()
{
$this->crud->addFields([
[
'name' => 'name',
Expand Down Expand Up @@ -102,7 +130,6 @@ public function setFields()
'type' => 'attribute_types',
]
]);

}

public function store(StoreRequest $request)
Expand Down
38 changes: 36 additions & 2 deletions app/Http/Controllers/Admin/AttributeSetCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public function setUp()
]
]);

/*
|--------------------------------------------------------------------------
| PERMISSIONS
|-------------------------------------------------------------------------
*/
$this->setPermissions();

/*
|--------------------------------------------------------------------------
| FIELDS
Expand All @@ -51,9 +58,37 @@ public function setUp()

}

public function setFields()
public function setPermissions()
{
// Get authenticated user
$user = auth()->user();

// Deny all accesses
$this->crud->denyAccess(['list', 'create', 'update', 'delete']);

// Allow list access
if ($user->can('list_attribute_sets')) {
$this->crud->allowAccess('list');
}

// Allow create access
if ($user->can('create_attribute_set')) {
$this->crud->allowAccess('create');
}

// Allow update access
if ($user->can('update_attribute_set')) {
$this->crud->allowAccess('update');
}

// Allow delete access
if ($user->can('delete_attribute_set')) {
$this->crud->allowAccess('delete');
}
}

public function setFields()
{
$this->crud->addFields([
[
'name' => 'name',
Expand All @@ -70,7 +105,6 @@ public function setFields()
'pivot' => true,
]
]);

}

public function ajaxGetAttributesBySetId(Request $request, Attribute $attribute)
Expand Down
38 changes: 36 additions & 2 deletions app/Http/Controllers/Admin/CarrierCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public function setUp()
]
]);

/*
|--------------------------------------------------------------------------
| PERMISSIONS
|-------------------------------------------------------------------------
*/
$this->setPermissions();

/*
|--------------------------------------------------------------------------
| FIELDS
Expand All @@ -51,9 +58,37 @@ public function setUp()

}

public function setFields()
public function setPermissions()
{
// Get authenticated user
$user = auth()->user();

// Deny all accesses
$this->crud->denyAccess(['list', 'create', 'update', 'delete']);

// Allow list access
if ($user->can('list_carriers')) {
$this->crud->allowAccess('list');
}

// Allow create access
if ($user->can('create_carrier')) {
$this->crud->allowAccess('create');
}

// Allow update access
if ($user->can('update_carrier')) {
$this->crud->allowAccess('update');
}

// Allow delete access
if ($user->can('delete_carrier')) {
$this->crud->allowAccess('delete');
}
}

public function setFields()
{
$this->crud->addFields([
[
'name' => 'name',
Expand Down Expand Up @@ -83,7 +118,6 @@ public function setFields()
'prefix' => 'uploads/carriers/'
]
]);

}


Expand Down
Loading

0 comments on commit 14bf810

Please sign in to comment.