44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Request;
|
|
use App\Models\Permissions\Permission;
|
|
|
|
class Permissions extends Controller
|
|
{
|
|
/**
|
|
* Display all permissions
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$permissions = Permission::whereNull('parent_id')->get();
|
|
|
|
return view('admin/permissions.index', compact('permissions'));
|
|
}
|
|
|
|
/**
|
|
* Setup default permissions
|
|
*
|
|
* @param Request $request
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function setDefault(Request $request)
|
|
{
|
|
Permission::where('default', true)
|
|
->update(['default' => false]);
|
|
|
|
$permissions = $request->permissions;
|
|
|
|
Permission::whereIn('string_id', array_keys($permissions))
|
|
->update(['default' => true]);
|
|
|
|
return redirect()
|
|
->back()
|
|
->with('success', trans('admin/permissions.defaultSuccessfullySet'));
|
|
}
|
|
}
|