mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-11 16:14:18 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
3a30f04b51
|
@ -8,6 +8,7 @@ use App\Http\Transformers\GroupsTransformer;
|
|||
use App\Models\Group;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class GroupsController extends Controller
|
||||
{
|
||||
/**
|
||||
|
@ -19,6 +20,8 @@ class GroupsController extends Controller
|
|||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->authorize('superadmin');
|
||||
|
||||
$this->authorize('view', Group::class);
|
||||
$allowed_columns = ['id', 'name', 'created_at', 'users_count'];
|
||||
|
||||
|
@ -59,9 +62,11 @@ class GroupsController extends Controller
|
|||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->authorize('create', Group::class);
|
||||
$this->authorize('superadmin');
|
||||
$group = new Group;
|
||||
$group->fill($request->all());
|
||||
|
||||
$group->name = $request->input('name');
|
||||
$group->permissions = $request->input('permissions'); // Todo - some JSON validation stuff here
|
||||
|
||||
if ($group->save()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $group, trans('admin/groups/message.create.success')));
|
||||
|
@ -80,7 +85,7 @@ class GroupsController extends Controller
|
|||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$this->authorize('view', Group::class);
|
||||
$this->authorize('superadmin');
|
||||
$group = Group::findOrFail($id);
|
||||
|
||||
return (new GroupsTransformer)->transformGroup($group);
|
||||
|
@ -97,9 +102,11 @@ class GroupsController extends Controller
|
|||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$this->authorize('update', Group::class);
|
||||
$this->authorize('superadmin');
|
||||
$group = Group::findOrFail($id);
|
||||
$group->fill($request->all());
|
||||
|
||||
$group->name = $request->input('name');
|
||||
$group->permissions = $request->input('permissions'); // Todo - some JSON validation stuff here
|
||||
|
||||
if ($group->save()) {
|
||||
return response()->json(Helper::formatStandardApiResponse('success', $group, trans('admin/groups/message.update.success')));
|
||||
|
@ -118,9 +125,8 @@ class GroupsController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->authorize('delete', Group::class);
|
||||
$this->authorize('superadmin');
|
||||
$group = Group::findOrFail($id);
|
||||
$this->authorize('delete', $group);
|
||||
$group->delete();
|
||||
|
||||
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/groups/message.delete.success')));
|
||||
|
|
|
@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Auth;
|
|||
use Illuminate\Http\Request;
|
||||
use Laravel\Passport\TokenRepository;
|
||||
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use DB;
|
||||
|
||||
class ProfileController extends Controller
|
||||
|
|
|
@ -16,7 +16,7 @@ use App\Models\User;
|
|||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
|
|
@ -8,7 +8,7 @@ use App\Models\Setting;
|
|||
use App\Models\User;
|
||||
use App\Notifications\CurrentInventory;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class CheckPermissions
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Accessory;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace App\Http\Transformers;
|
|||
use App\Helpers\Helper;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetMaintenance;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class AssetMaintenancesTransformer
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace App\Http\Transformers;
|
|||
use App\Helpers\Helper;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Setting;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Category;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Company;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Http\Transformers;
|
||||
|
||||
use App\Models\Asset;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class ComponentsAssetsTransformer
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Component;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Consumable;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Department;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace App\Http\Transformers;
|
|||
use App\Helpers\Helper;
|
||||
use App\Models\Depreciable;
|
||||
use App\Models\Depreciation;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class DepreciationsTransformer
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Group;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class GroupsTransformer
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class LicenseSeatsTransformer
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\License;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class LicensesTransformer
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Manufacturer;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Models\PredefinedKit;
|
||||
use App\Models\SnipeModel;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Statuslabel;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class StatuslabelsTransformer
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Supplier;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Http\Transformers;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\User;
|
||||
use Gate;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class UsersTransformer
|
||||
|
|
|
@ -16,6 +16,11 @@ class Group extends SnipeModel
|
|||
'name' => 'required|min:2|max:255',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'permissions'
|
||||
];
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
|
|
Loading…
Reference in a new issue