diff --git a/.gitattributes b/.gitattributes index 2125666142..5ad9d096e2 100755 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ -* text=auto \ No newline at end of file +* text=auto +public/js/** binary +public/css/** binary diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 50d83db583..e24f49f61e 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -606,38 +606,32 @@ class Helper $extension = substr(strrchr($filename,'.'),1); - if ($extension) { - switch ($extension) { - case 'jpg': - case 'jpeg': - case 'gif': - case 'png': - return "fa fa-file-image-o"; - break; - case 'doc': - case 'docx': - return "fa fa-file-word-o"; - break; - case 'xls': - case 'xlsx': - return "fa fa-file-excel-o"; - break; - case 'zip': - case 'rar': - return "fa fa-file-archive-o"; - break; - case 'pdf': - return "fa fa-file-pdf-o"; - break; - case 'txt': - return "fa fa-file-text-o"; - break; - case 'lic': - return "fa fa-floppy-o"; - break; - default: - return "fa fa-file-o"; - } + $allowedExtensionMap = [ + // Images + 'jpg' => 'fa fa-file-image-o', + 'jpeg' => 'fa fa-file-image-o', + 'gif' => 'fa fa-file-image-o', + 'png' => 'fa fa-file-image-o', + // word + 'doc' => 'fa fa-file-word-o', + 'docx' => 'fa fa-file-word-o', + // Excel + 'xls' => 'fa fa-file-excel-o', + 'xlsx' => 'fa fa-file-excel-o', + // archive + 'zip' => 'fa fa-file-archive-o', + 'rar' => 'fa fa-file-archive-o', + //Text + 'txt' => 'fa fa-file-text-o', + 'rtf' => 'fa fa-file-text-o', + 'xml' => 'fa fa-file-text-o', + // Misc + 'pdf' => 'fa fa-file-pdf-o', + 'lic' => 'fa fa-file-floppy-o', + ]; + + if ($extension && array_key_exists($extension, $allowedExtensionMap)) { + return $allowedExtensionMap[$extension]; } return "fa fa-file-o"; } diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php index 7422e64052..ae085c0f35 100644 --- a/app/Http/Controllers/Api/CategoriesController.php +++ b/app/Http/Controllers/Api/CategoriesController.php @@ -120,16 +120,12 @@ class CategoriesController extends Controller public function destroy($id) { $this->authorize('delete', Category::class); - $category = Category::withCount('models as models_count', 'accessories as accessories_count','consumables as consumables_count','components as components_count')->findOrFail($id); + $category = Category::findOrFail($id); - if ($category->models_count > 0) { - return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>'model']))); - } elseif ($category->accessories_count > 0) { - return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>'accessory']))); - } elseif ($category->consumables_count > 0) { - return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>'consumable']))); - } elseif ($category->components_count > 0) { - return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>'component']))); + if (!$category->isDeletable()) { + return response()->json( + Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>$category->category_type])) + ); } $category->delete(); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/categories/message.delete.success'))); diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php index e07a895eee..c56ed9f871 100644 --- a/app/Http/Controllers/Api/CompaniesController.php +++ b/app/Http/Controllers/Api/CompaniesController.php @@ -48,7 +48,7 @@ class CompaniesController extends Controller // Check to make sure the limit is not higher than the max allowed ((config('app.max_results') >= $request->input('limit')) && ($request->filled('limit'))) ? $limit = $request->input('limit') : $limit = config('app.max_results'); - + $order = $request->input('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; $companies->orderBy($sort, $order); @@ -133,28 +133,17 @@ class CompaniesController extends Controller */ public function destroy($id) { - $this->authorize('delete', Company::class); - $company = Company::findOrFail($id); - $this->authorize('delete', $company); + $this->authorize('delete', Company::class); + $company = Company::findOrFail($id); + $this->authorize('delete', $company); - try { - $company->delete(); + if ( !$company->isDeletable() ) { return response() - ->json(Helper::formatStandardApiResponse('success', null, trans('admin/companies/message.delete.success'))); - } catch (\Illuminate\Database\QueryException $exception) { - /* - * NOTE: This happens when there's a foreign key constraint violation - * For example when rows in other tables are referencing this company - */ - if ($exception->getCode() == 23000) { - return response() ->json(Helper::formatStandardApiResponse('error', null, trans('admin/companies/message.assoc_users'))); - - } else { - throw $exception; - } } - + $company->delete(); + return response() + ->json(Helper::formatStandardApiResponse('success', null, trans('admin/companies/message.delete.success'))); } /** diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.php index 2f6a2d8eac..cd2917b4f3 100644 --- a/app/Http/Controllers/Api/LocationsController.php +++ b/app/Http/Controllers/Api/LocationsController.php @@ -179,6 +179,10 @@ class LocationsController extends Controller { $this->authorize('delete', Location::class); $location = Location::findOrFail($id); + if(!$location->isDeletable()) { + return response() + ->json(Helper::formatStandardApiResponse('error', null, trans('admin/companies/message.assoc_users'))); + } $this->authorize('delete', $location); $location->delete(); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/locations/message.delete.success'))); @@ -259,4 +263,4 @@ class LocationsController extends Controller } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/Api/ManufacturersController.php b/app/Http/Controllers/Api/ManufacturersController.php index f8867a4132..6b9212137f 100644 --- a/app/Http/Controllers/Api/ManufacturersController.php +++ b/app/Http/Controllers/Api/ManufacturersController.php @@ -125,15 +125,15 @@ class ManufacturersController extends Controller { $this->authorize('delete', Manufacturer::class); - $manufacturer = Manufacturer::withCount('assets as assets_count', 'licenses as licenses_count', 'consumables as consumables_count', 'accessories as accessories_count', 'models as models_count' )->findOrFail($id); + $manufacturer = Manufacturer::findOrFail($id); $this->authorize('delete', $manufacturer); - if (($manufacturer->assets_count == 0) && ($manufacturer->licenses_count==0) && ($manufacturer->consumables_count==0) && ($manufacturer->accessories_count==0) && ($manufacturer->models_count==0) && ($manufacturer->deleted_at=='')) { + if ($manufacturer->isDeletable()) { $manufacturer->delete(); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/manufacturers/message.delete.success'))); } - return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/manufacturers/message.delete.error'))); + return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/manufacturers/message.assoc_users'))); diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index 8526de08fd..4c0ac970a7 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -55,14 +55,14 @@ class AssetCheckinController extends Controller return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); } + if (is_null($target = $asset->assignedTo)) { + return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in')); + } $this->authorize('checkin', $asset); if ($asset->assignedType() == Asset::USER) { $user = $asset->assignedTo; } - if (is_null($target = $asset->assignedTo)) { - return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in')); - } $asset->expected_checkin = null; $asset->last_checkout = null; @@ -89,7 +89,6 @@ class AssetCheckinController extends Controller // Was the asset updated? if ($asset->save()) { - event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at)); if ((isset($user)) && ($backto =='user')) { diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 6d354869d3..c6228d67d1 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -63,11 +63,7 @@ class AssetsController extends Controller public function index(Request $request) { $this->authorize('index', Asset::class); - if ($request->filled('company_id')) { - $company = Company::find($request->input('company_id')); - } else { - $company = null; - } + $company = Company::find($request->input('company_id')); return view('hardware/index')->with('company', $company); } diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 1727607c65..228b7f544d 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -206,9 +206,11 @@ class BulkAssetsController extends Controller $asset_ids = array_filter($request->get('selected_assets')); - foreach ($asset_ids as $asset_id) { - if ($target->id == $asset_id && request('checkout_to_type') =='asset') { - return redirect()->back()->with('error', 'You cannot check an asset out to itself.'); + if(request('checkout_to_type') =='asset') { + foreach ($asset_ids as $asset_id) { + if ($target->id == $asset_id) { + return redirect()->back()->with('error', 'You cannot check an asset out to itself.'); + } } } $checkout_at = date("Y-m-d H:i:s"); diff --git a/app/Http/Controllers/CategoriesController.php b/app/Http/Controllers/CategoriesController.php index 6623276bce..2383dc5530 100755 --- a/app/Http/Controllers/CategoriesController.php +++ b/app/Http/Controllers/CategoriesController.php @@ -159,18 +159,12 @@ class CategoriesController extends Controller { $this->authorize('delete', Category::class); // Check if the category exists - if (is_null($category = Category::withCount('models as models_count', 'accessories as accessories_count','consumables as consumables_count','components as components_count')->findOrFail($categoryId))) { + if (is_null($category = Category::findOrFail($categoryId))) { return redirect()->route('categories.index')->with('error', trans('admin/categories/message.not_found')); } - if ($category->models_count > 0) { - return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'model'])); - } elseif ($category->accessories_count > 0) { - return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'accessory'])); - } elseif ($category->consumables_count > 0) { - return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'consumable'])); - } elseif ($category->components_count > 0) { - return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'component'])); + if (!$category->isDeletable()) { + return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=> $category->category_type ])); } Storage::disk('public')->delete('categories'.'/'.$category->image); diff --git a/app/Http/Controllers/CompaniesController.php b/app/Http/Controllers/CompaniesController.php index 2a61ffe968..369672354b 100644 --- a/app/Http/Controllers/CompaniesController.php +++ b/app/Http/Controllers/CompaniesController.php @@ -113,7 +113,7 @@ final class CompaniesController extends Controller $company->name = $request->input('name'); - + $company = $request->handleImages($company,600, public_path().'/uploads/companies'); @@ -140,34 +140,24 @@ final class CompaniesController extends Controller return redirect()->route('companies.index') ->with('error', trans('admin/companies/message.not_found')); } - + $this->authorize('delete', $company); - - try { - - if ($company->image) { - try { - Storage::disk('public')->delete('companies'.'/'.$company->image); - } catch (\Exception $e) { - \Log::debug($e); - } - } - - $company->delete(); + if(!$company->isDeletable()) { return redirect()->route('companies.index') - ->with('success', trans('admin/companies/message.delete.success')); - } catch (\Illuminate\Database\QueryException $exception) { - /* - * NOTE: This happens when there's a foreign key constraint violation - * For example when rows in other tables are referencing this company - */ - if ($exception->getCode() == 23000) { - return redirect()->route('companies.index') ->with('error', trans('admin/companies/message.assoc_users')); - } - - throw $exception; } + + if ($company->image) { + try { + Storage::disk('public')->delete('companies'.'/'.$company->image); + } catch (\Exception $e) { + \Log::debug($e); + } + } + + $company->delete(); + return redirect()->route('companies.index') + ->with('success', trans('admin/companies/message.delete.success')); } public function show($id) { diff --git a/app/Http/Controllers/Licenses/LicenseFilesController.php b/app/Http/Controllers/Licenses/LicenseFilesController.php index 04e48ee9b6..7fe5cc78ef 100644 --- a/app/Http/Controllers/Licenses/LicenseFilesController.php +++ b/app/Http/Controllers/Licenses/LicenseFilesController.php @@ -28,18 +28,16 @@ class LicenseFilesController extends Controller public function store(AssetFileRequest $request, $licenseId = null) { $license = License::find($licenseId); - // the license is valid - $destinationPath = config('app.private_uploads').'/licenses'; if (isset($license->id)) { $this->authorize('update', $license); - if (Request::hasFile('file')) { + if ($request->hasFile('file')) { if (!Storage::exists('private_uploads/licenses')) Storage::makeDirectory('private_uploads/licenses', 775); $upload_success = false; - foreach (Input::file('file') as $file) { + foreach ($request->file('file') as $file) { $extension = $file->getClientOriginalExtension(); $file_name = 'license-'.$license->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension; diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 86476867c1..41263efd7e 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -171,18 +171,14 @@ class LocationsController extends Controller return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found')); } - if (($location->users()) && ($location->users()->count() > 0)) { + if ($location->users()->count() > 0) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users')); - - } elseif (($location->children) && ($location->children->count() > 0)) { + } elseif ($location->children()->count() > 0) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc')); - - } elseif (($location->assets()) && ($location->assets()->count() > 0)) { + } elseif ($location->assets()->count() > 0) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets')); - - } elseif (($location->assignedassets()) && ($location->assignedassets()->count() > 0)) { + } elseif ($location->assignedassets()->count() > 0) { return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets')); - } if ($location->image) { diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index dde37b090d..436f197a77 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -162,7 +162,7 @@ class ManufacturersController extends Controller return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.not_found')); } - if ($manufacturer->models_count > 0) { + if (!$manufacturer->isDeletable()) { return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.assoc_users')); } @@ -174,7 +174,6 @@ class ManufacturersController extends Controller } } - // Delete the manufacturer $manufacturer->delete(); // Redirect to the manufacturers management page diff --git a/app/Http/Controllers/ModalController.php b/app/Http/Controllers/ModalController.php index d5b993d3a0..61a3cf10b6 100644 --- a/app/Http/Controllers/ModalController.php +++ b/app/Http/Controllers/ModalController.php @@ -6,47 +6,15 @@ use App\Helpers\Helper; class ModalController extends Controller { - function location() { - return view('modals.location'); - } + function show($type, $itemId = null) { + $view = view("modals.${type}"); - function model() { - return view('modals.model'); - } - - function statuslabel() { - return view('modals.statuslabel')->with('statuslabel_types', Helper::statusTypeList()); - } - - function supplier() { - return view('modals.supplier'); - } - - function user() { - return view('modals.user'); - } - - function category() { - return view('modals.category'); - } - - function manufacturer() { - return view('modals.manufacturer'); - } - - function kitModel() { - return view('modals.kit-model'); - } - - function kitLicense() { - return view('modals.kit-license'); - } - - function kitConsumable() { - return view('modals.kit-consumable'); - } - - function kitAccessory() { - return view('modals.kit-accessory'); + if($type == "statuslabel") { + $view->with('statuslabel_types', Helper::statusTypeList()); + } + if(in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) { + $view->with('kitId', $itemId); + } + return $view; } } diff --git a/app/Http/Controllers/SuppliersController.php b/app/Http/Controllers/SuppliersController.php index 20d6beac37..d82dca4d8d 100755 --- a/app/Http/Controllers/SuppliersController.php +++ b/app/Http/Controllers/SuppliersController.php @@ -106,7 +106,7 @@ class SuppliersController extends Controller * @return \Illuminate\Http\RedirectResponse * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function update($supplierId = null, ImageUploadRequest $request) + public function update($supplierId, ImageUploadRequest $request) { $this->authorize('update', Supplier::class); // Check if the supplier exists diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index ea150f4b84..499eaa3a1c 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -33,9 +33,6 @@ class BulkUsersController extends Controller // Make sure there were users selected if (($request->filled('ids')) && (count($request->input('ids')) > 0)) { - - $statuslabel_list = Helper::statusLabelList(); - // Get the list of affected users $users = User::whereIn('id', array_keys(request('ids'))) ->with('groups', 'assets', 'licenses', 'accessories')->get(); @@ -45,17 +42,15 @@ class BulkUsersController extends Controller ->with('groups', Group::pluck('name', 'id')); } elseif ($request->input('bulk_actions') == 'delete') { - return view('users/confirm-bulk-delete', compact('users', 'statuslabel_list')); + return view('users/confirm-bulk-delete', compact('users', Helper::statusLabelList();)); } elseif ($request->input('bulk_actions') == 'bulkpasswordreset') { - if ($users) { - foreach ($users as $user) { - if (($user->activated=='1') && ($user->email!='')) { - $credentials = ['email' => $user->email]; - Password::sendResetLink($credentials, function (Message $message) { - $message->subject($this->getEmailSubject()); - }); - } + foreach ($users as $user) { + if (($user->activated=='1') && ($user->email!='')) { + $credentials = ['email' => $user->email]; + Password::sendResetLink($credentials, function (Message $message) { + $message->subject($this->getEmailSubject()); + }); } } return redirect()->back()->with('success', trans('admin/users/message.password_resets_sent')); diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 3c10102560..0e1953f02b 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -204,7 +204,7 @@ class UsersController extends Controller * @return \Illuminate\Http\RedirectResponse * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function update(Request $request, $id = null) + public function update(SaveUserRequest $request, $id = null) { // We need to reverse the UI specific logic for our // permissions here before we update the user. @@ -221,25 +221,20 @@ class UsersController extends Controller try { $user = User::findOrFail($id); - app('App\Http\Requests\SaveUserRequest'); - - if ($user->id == $request->input('manager_id')) { - return redirect()->back()->withInput()->with('error', 'You cannot be your own manager.'); - } - $this->authorize('update', $user); - // Figure out of this user was an admin before this edit - $orig_permissions_array = $user->decodePermissions(); - $orig_superuser = '0'; - if (is_array($orig_permissions_array)) { - if (array_key_exists('superuser', $orig_permissions_array)) { - $orig_superuser = $orig_permissions_array['superuser']; - } - } } catch (ModelNotFoundException $e) { return redirect()->route('users.index') ->with('error', trans('admin/users/message.user_not_found', compact('id'))); } + $this->authorize('update', $user); + // Figure out of this user was an admin before this edit + $orig_permissions_array = $user->decodePermissions(); + $orig_superuser = '0'; + if (is_array($orig_permissions_array)) { + if (array_key_exists('superuser', $orig_permissions_array)) { + $orig_superuser = $orig_permissions_array['superuser']; + } + } // Only save groups if the user is a super user if (Auth::user()->isSuperUser()) { @@ -247,13 +242,11 @@ class UsersController extends Controller } + // Update the user if ($request->filled('username')) { $user->username = $request->input('username'); } $user->email = $request->input('email'); - - - // Update the user $user->first_name = $request->input('first_name'); $user->last_name = $request->input('last_name'); $user->two_factor_optin = $request->input('two_factor_optin') ?: 0; @@ -382,7 +375,7 @@ class UsersController extends Controller { $this->authorize('update', User::class); // Get user information - if (!$user = User::onlyTrashed()->find($id)) { + if (!User::onlyTrashed()->find($id)) { return redirect()->route('users.index')->with('error', trans('admin/users/messages.user_not_found')); } diff --git a/app/Http/Requests/SaveUserRequest.php b/app/Http/Requests/SaveUserRequest.php index 7399ff808d..ed44fc0939 100644 --- a/app/Http/Requests/SaveUserRequest.php +++ b/app/Http/Requests/SaveUserRequest.php @@ -33,7 +33,9 @@ class SaveUserRequest extends FormRequest public function rules() { - $rules = []; + $rules = [ + 'manager_id' => "nullable|exists:users,id|different:users.id" + ]; switch($this->method()) { diff --git a/app/Http/Transformers/AccessoriesTransformer.php b/app/Http/Transformers/AccessoriesTransformer.php index 13a62c70b3..8b56ae05f6 100644 --- a/app/Http/Transformers/AccessoriesTransformer.php +++ b/app/Http/Transformers/AccessoriesTransformer.php @@ -45,10 +45,10 @@ class AccessoriesTransformer ]; $permissions_array['available_actions'] = [ - 'checkout' => Gate::allows('checkout', Accessory::class) ? true : false, + 'checkout' => Gate::allows('checkout', Accessory::class), 'checkin' => false, - 'update' => Gate::allows('update', Accessory::class) ? true : false, - 'delete' => Gate::allows('delete', Accessory::class) ? true : false, + 'update' => Gate::allows('update', Accessory::class) , + 'delete' => Gate::allows('delete', Accessory::class), ]; $permissions_array['user_can_checkout'] = false; diff --git a/app/Http/Transformers/AssetMaintenancesTransformer.php b/app/Http/Transformers/AssetMaintenancesTransformer.php index 8b93031886..49c1b38b65 100644 --- a/app/Http/Transformers/AssetMaintenancesTransformer.php +++ b/app/Http/Transformers/AssetMaintenancesTransformer.php @@ -58,8 +58,8 @@ class AssetMaintenancesTransformer ]; $permissions_array['available_actions'] = [ - 'update' => (bool) Gate::allows('update', Asset::class), - 'delete' => (bool) Gate::allows('delete', Asset::class), + 'update' => Gate::allows('update', Asset::class), + 'delete' => Gate::allows('delete', Asset::class), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/AssetModelsTransformer.php b/app/Http/Transformers/AssetModelsTransformer.php index 4b2658e739..3f561b7b9f 100644 --- a/app/Http/Transformers/AssetModelsTransformer.php +++ b/app/Http/Transformers/AssetModelsTransformer.php @@ -54,10 +54,10 @@ class AssetModelsTransformer ]; $permissions_array['available_actions'] = [ - 'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false, - 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->assets_count==0) && ($assetmodel->deleted_at=='')) ? true : false, - 'clone' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at=='')) , - 'restore' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at!='')) ? true : false, + 'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')), + 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->assets_count==0)), + 'clone' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at=='')), + 'restore' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at!='')), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 882b60ff76..400a5dd111 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -114,20 +114,20 @@ class AssetsTransformer } $permissions_array['available_actions'] = [ - 'checkout' => (bool) Gate::allows('checkout', Asset::class), - 'checkin' => (bool) Gate::allows('checkin', Asset::class), - 'clone' => Gate::allows('create', Asset::class) ? true : false, + 'checkout' => Gate::allows('checkout', Asset::class), + 'checkin' => Gate::allows('checkin', Asset::class), + 'clone' => Gate::allows('create', Asset::class), 'restore' => false, 'update' => (bool) Gate::allows('update', Asset::class), - 'delete' => ($asset->assigned_to=='' && Gate::allows('delete', Asset::class) ? true : false), + 'delete' => ($asset->assigned_to=='' && Gate::allows('delete', Asset::class)), ]; if ($asset->deleted_at!='') { $permissions_array['available_actions'] = [ 'checkout' => true, 'checkin' => false, - 'clone' => Gate::allows('create', Asset::class) ? true : false, - 'restore' => Gate::allows('create', Asset::class) ? true : false, + 'clone' => Gate::allows('create', Asset::class), + 'restore' => Gate::allows('create', Asset::class), 'update' => false, 'delete' => false, ]; diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index a76e8c0c19..d10c2ee4c3 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -27,10 +27,11 @@ class CategoriesTransformer 'id' => (int) $category->id, 'name' => e($category->name), 'image' => ($category->image) ? Storage::disk('public')->url('categories/'.e($category->image)) : null, - 'category_type' => e($category->category_type), - 'eula' => ($category->getEula()) ? true : false, - 'checkin_email' => ($category->checkin_email =='1') ? true : false, - 'require_acceptance' => ($category->require_acceptance =='1') ? true : false, + 'category_type' => ucwords(e($category->category_type)), + 'eula' => ($category->getEula()), + 'checkin_email' => ($category->checkin_email =='1'), + 'require_acceptance' => ($category->require_acceptance == '1'), + 'item_count' => (int) $category->itemCount(), 'assets_count' => (int) $category->assets_count, 'accessories_count' => (int) $category->accessories_count, 'consumables_count' => (int) $category->consumables_count, @@ -41,8 +42,8 @@ class CategoriesTransformer ]; $permissions_array['available_actions'] = [ - 'update' => Gate::allows('update', Category::class) ? true : false, - 'delete' => (Gate::allows('delete', Category::class) && ($category->assets_count == 0) && ($category->accessories_count == 0) && ($category->consumables_count == 0) && ($category->components_count == 0) && ($category->licenses_count == 0)) ? true : false, + 'update' => Gate::allows('update', Category::class), + 'delete' => $category->isDeletable(), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/CompaniesTransformer.php b/app/Http/Transformers/CompaniesTransformer.php index 616353e9a8..4460b30c14 100644 --- a/app/Http/Transformers/CompaniesTransformer.php +++ b/app/Http/Transformers/CompaniesTransformer.php @@ -38,8 +38,8 @@ class CompaniesTransformer ]; $permissions_array['available_actions'] = [ - 'update' => Gate::allows('update', Company::class) ? true : false, - 'delete' => (Gate::allows('delete', Company::class) && ($company->assets_count == 0) && ($company->accessories_count == 0) && ($company->consumables_count == 0) && ($company->components_count == 0) && ($company->users_count == 0)) ? true : false, + 'update' => Gate::allows('update', Company::class), + 'delete' => $company->isDeletable() ]; $array += $permissions_array; diff --git a/app/Http/Transformers/ComponentsAssetsTransformer.php b/app/Http/Transformers/ComponentsAssetsTransformer.php index a38236e726..8ce3a8600d 100644 --- a/app/Http/Transformers/ComponentsAssetsTransformer.php +++ b/app/Http/Transformers/ComponentsAssetsTransformer.php @@ -28,10 +28,10 @@ class ComponentsAssetsTransformer ]; $permissions_array['available_actions'] = [ - 'checkout' => Gate::allows('checkout', Asset::class) ? true : false, - 'checkin' => Gate::allows('checkin', Asset::class) ? true : false, - 'update' => Gate::allows('update', Asset::class) ? true : false, - 'delete' => Gate::allows('delete', Asset::class) ? true : false, + 'checkout' => Gate::allows('checkout', Asset::class), + 'checkin' => Gate::allows('checkin', Asset::class), + 'update' => Gate::allows('update', Asset::class), + 'delete' => Gate::allows('delete', Asset::class), ]; diff --git a/app/Http/Transformers/ComponentsTransformer.php b/app/Http/Transformers/ComponentsTransformer.php index f81da099d4..c27deb2a1f 100644 --- a/app/Http/Transformers/ComponentsTransformer.php +++ b/app/Http/Transformers/ComponentsTransformer.php @@ -49,10 +49,10 @@ class ComponentsTransformer ]; $permissions_array['available_actions'] = [ - 'checkout' => (bool) Gate::allows('checkout', Component::class), - 'checkin' => (bool) Gate::allows('checkin', Component::class), - 'update' => (bool) Gate::allows('update', Component::class), - 'delete' => (bool) Gate::allows('delete', Component::class), + 'checkout' => Gate::allows('checkout', Component::class), + 'checkin' => Gate::allows('checkin', Component::class), + 'update' => Gate::allows('update', Component::class), + 'delete' => Gate::allows('delete', Component::class), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/ConsumablesTransformer.php b/app/Http/Transformers/ConsumablesTransformer.php index 9d51c5e5c4..c82299de98 100644 --- a/app/Http/Transformers/ConsumablesTransformer.php +++ b/app/Http/Transformers/ConsumablesTransformer.php @@ -48,10 +48,10 @@ class ConsumablesTransformer } $permissions_array['available_actions'] = [ - 'checkout' => Gate::allows('checkout', Consumable::class) ? true : false, - 'checkin' => Gate::allows('checkin', Consumable::class) ? true : false, - 'update' => Gate::allows('update', Consumable::class) ? true : false, - 'delete' => Gate::allows('delete', Consumable::class) ? true : false, + 'checkout' => Gate::allows('checkout', Consumable::class), + 'checkin' => Gate::allows('checkin', Consumable::class), + 'update' => Gate::allows('update', Consumable::class), + 'delete' => Gate::allows('delete', Consumable::class), ]; $array += $permissions_array; return $array; diff --git a/app/Http/Transformers/DepartmentsTransformer.php b/app/Http/Transformers/DepartmentsTransformer.php index 83517ccd43..5429ba684f 100644 --- a/app/Http/Transformers/DepartmentsTransformer.php +++ b/app/Http/Transformers/DepartmentsTransformer.php @@ -47,8 +47,8 @@ class DepartmentsTransformer ]; $permissions_array['available_actions'] = [ - 'update' => Gate::allows('update', Department::class) ? true : false, - 'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0) && ($department->deleted_at=='')) ? true : false, + 'update' => Gate::allows('update', Department::class), + 'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/DepreciationsTransformer.php b/app/Http/Transformers/DepreciationsTransformer.php index 5f66eef8b4..0b9d011e23 100644 --- a/app/Http/Transformers/DepreciationsTransformer.php +++ b/app/Http/Transformers/DepreciationsTransformer.php @@ -29,8 +29,8 @@ class DepreciationsTransformer ]; $permissions_array['available_actions'] = [ - 'update' => Gate::allows('update', Depreciation::class) ? true : false, - 'delete' => Gate::allows('delete', Depreciation::class) ? true : false, + 'update' => Gate::allows('update', Depreciation::class), + 'delete' => Gate::allows('delete', Depreciation::class), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/LicenseSeatsTransformer.php b/app/Http/Transformers/LicenseSeatsTransformer.php index 8811f3784c..f7685db167 100644 --- a/app/Http/Transformers/LicenseSeatsTransformer.php +++ b/app/Http/Transformers/LicenseSeatsTransformer.php @@ -46,15 +46,15 @@ class LicenseSeatsTransformer 'name'=> e($seat->location()->name) ] : null, 'reassignable' => (bool) $seat->license->reassignable, - 'user_can_checkout' => (($seat->assigned_to=='') && ($seat->asset_id=='')) ? true : false, + 'user_can_checkout' => (($seat->assigned_to=='') && ($seat->asset_id=='')), ]; $permissions_array['available_actions'] = [ - 'checkout' => Gate::allows('checkout', License::class) ? true : false, - 'checkin' => Gate::allows('checkin', License::class) ? true : false, - 'clone' => Gate::allows('create', License::class) ? true : false, - 'update' => Gate::allows('update', License::class) ? true : false, - 'delete' => Gate::allows('delete', License::class) ? true : false, + 'checkout' => Gate::allows('checkout', License::class), + 'checkin' => Gate::allows('checkin', License::class), + 'clone' => Gate::allows('create', License::class), + 'update' => Gate::allows('update', License::class), + 'delete' => Gate::allows('delete', License::class), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/LicensesTransformer.php b/app/Http/Transformers/LicensesTransformer.php index 5a668b2f62..344213f939 100644 --- a/app/Http/Transformers/LicensesTransformer.php +++ b/app/Http/Transformers/LicensesTransformer.php @@ -45,11 +45,11 @@ class LicensesTransformer ]; $permissions_array['available_actions'] = [ - 'checkout' => Gate::allows('checkout', License::class) ? true : false, - 'checkin' => Gate::allows('checkin', License::class) ? true : false, - 'clone' => Gate::allows('create', License::class) ? true : false, - 'update' => Gate::allows('update', License::class) ? true : false, - 'delete' => Gate::allows('delete', License::class) ? true : false, + 'checkout' => Gate::allows('checkout', License::class), + 'checkin' => Gate::allows('checkin', License::class), + 'clone' => Gate::allows('create', License::class), + 'update' => Gate::allows('update', License::class), + 'delete' => Gate::allows('delete', License::class), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php index b5e51a37ce..92f5cc965d 100644 --- a/app/Http/Transformers/LocationsTransformer.php +++ b/app/Http/Transformers/LocationsTransformer.php @@ -61,7 +61,7 @@ class LocationsTransformer $permissions_array['available_actions'] = [ 'update' => Gate::allows('update', Location::class) ? true : false, - 'delete' => (Gate::allows('delete', Location::class) && ($location->assigned_assets_count==0) && ($location->assets_count==0) && ($location->users_count==0) && ($location->deleted_at=='')) ? true : false, + 'delete' => $location->isDeletable(), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/ManufacturersTransformer.php b/app/Http/Transformers/ManufacturersTransformer.php index 860652ef0a..1cdf5dd3fe 100644 --- a/app/Http/Transformers/ManufacturersTransformer.php +++ b/app/Http/Transformers/ManufacturersTransformer.php @@ -41,9 +41,9 @@ class ManufacturersTransformer ]; $permissions_array['available_actions'] = [ - 'update' => (($manufacturer->deleted_at=='') && (Gate::allows('update', Manufacturer::class))) ? true : false, - 'restore' => (($manufacturer->deleted_at!='') && (Gate::allows('create', Manufacturer::class))) ? true : false, - 'delete' => (Gate::allows('delete', Manufacturer::class) && ($manufacturer->assets_count == 0) && ($manufacturer->licenses_count==0) && ($manufacturer->consumables_count==0) && ($manufacturer->accessories_count==0) && ($manufacturer->deleted_at=='')) ? true : false, + 'update' => (($manufacturer->deleted_at=='') && (Gate::allows('update', Manufacturer::class))), + 'restore' => (($manufacturer->deleted_at!='') && (Gate::allows('create', Manufacturer::class))), + 'delete' => $manufacturer->isDeletable(), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/PredefinedKitsTransformer.php b/app/Http/Transformers/PredefinedKitsTransformer.php index f130a659df..57e3aa62f4 100644 --- a/app/Http/Transformers/PredefinedKitsTransformer.php +++ b/app/Http/Transformers/PredefinedKitsTransformer.php @@ -34,7 +34,7 @@ class PredefinedKitsTransformer $permissions_array['available_actions'] = [ 'update' => Gate::allows('update', PredefinedKit::class), 'delete' => Gate::allows('delete', PredefinedKit::class), - 'checkout' => Gate::allows('checkout', PredefinedKit::class) ? true : false, + 'checkout' => Gate::allows('checkout', PredefinedKit::class), // 'clone' => Gate::allows('create', PredefinedKit::class), // 'restore' => Gate::allows('create', PredefinedKit::class), ]; diff --git a/app/Http/Transformers/SuppliersTransformer.php b/app/Http/Transformers/SuppliersTransformer.php index 44f483deac..e24e399bd1 100644 --- a/app/Http/Transformers/SuppliersTransformer.php +++ b/app/Http/Transformers/SuppliersTransformer.php @@ -28,16 +28,16 @@ class SuppliersTransformer 'name' => e($supplier->name), 'image' => ($supplier->image) ? Storage::disk('public')->url('suppliers/'.e($supplier->image)) : null, 'url' => e($supplier->url), - 'address' => ($supplier->address) ? e($supplier->address) : null, - 'address2' => ($supplier->address2) ? e($supplier->address2) : null, - 'city' => ($supplier->city) ? e($supplier->city) : null, - 'state' => ($supplier->state) ? e($supplier->state) : null, - 'country' => ($supplier->country) ? e($supplier->country) : null, - 'zip' => ($supplier->zip) ? e($supplier->zip) : null, - 'fax' => ($supplier->fax) ? e($supplier->fax) : null, - 'phone' => ($supplier->phone) ? e($supplier->phone) : null, - 'email' => ($supplier->email) ? e($supplier->email) : null, - 'contact' => ($supplier->contact) ? e($supplier->contact) : null, + 'address' => e($supplier->address), + 'address2' => e($supplier->address2), + 'city' => e($supplier->city), + 'state' => e($supplier->state), + 'country' => e($supplier->country), + 'zip' => e($supplier->zip), + 'fax' => e($supplier->fax), + 'phone' => e($supplier->phone), + 'email' => e($supplier->email), + 'contact' => e($supplier->contact), 'assets_count' => (int) $supplier->assets_count, 'accessories_count' => (int) $supplier->accessories_count, 'licenses_count' => (int) $supplier->licenses_count, @@ -48,8 +48,8 @@ class SuppliersTransformer ]; $permissions_array['available_actions'] = [ - 'update' => Gate::allows('update', Supplier::class) ? true : false, - 'delete' => (Gate::allows('delete', Supplier::class) && ($supplier->assets_count == 0) && ($supplier->licenses_count == 0) && ($supplier->accessories_count == 0)) ? true : false, + 'update' => Gate::allows('update', Supplier::class), + 'delete' => (Gate::allows('delete', Supplier::class) && ($supplier->assets_count == 0) && ($supplier->licenses_count == 0) && ($supplier->accessories_count == 0)), ]; $array += $permissions_array; diff --git a/app/Http/Transformers/UsersTransformer.php b/app/Http/Transformers/UsersTransformer.php index 07b5fc1809..5f844d5883 100644 --- a/app/Http/Transformers/UsersTransformer.php +++ b/app/Http/Transformers/UsersTransformer.php @@ -66,10 +66,10 @@ class UsersTransformer ]; $permissions_array['available_actions'] = [ - 'update' => (Gate::allows('update', User::class) && ($user->deleted_at=='')) ? true : false, - 'delete' => (Gate::allows('delete', User::class) && ($user->deleted_at=='') && ($user->assets_count == 0) && ($user->licenses_count == 0) && ($user->accessories_count == 0) && ($user->consumables_count == 0)) ? true : false, + 'update' => (Gate::allows('update', User::class) && ($user->deleted_at=='')), + 'delete' => (Gate::allows('delete', User::class) && ($user->assets_count == 0) && ($user->licenses_count == 0) && ($user->accessories_count == 0) && ($user->consumables_count == 0)), 'clone' => (Gate::allows('create', User::class) && ($user->deleted_at=='')) , - 'restore' => (Gate::allows('create', User::class) && ($user->deleted_at!='')) ? true : false, + 'restore' => (Gate::allows('create', User::class) && ($user->deleted_at!='')), ]; $array += $permissions_array; diff --git a/app/Models/Category.php b/app/Models/Category.php index b42463addd..ae60a1d735 100755 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -5,6 +5,7 @@ use App\Http\Traits\UniqueUndeletedTrait; use App\Models\Traits\Searchable; use App\Presenters\Presentable; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\Gate; use Watson\Validating\ValidatingTrait; /** @@ -69,22 +70,35 @@ class Category extends SnipeModel ]; use Searchable; - + /** * The attributes that should be included when searching the model. - * + * * @var array */ protected $searchableAttributes = ['name', 'category_type']; /** * The relations and their attributes that should be included when searching the model. - * + * * @var array */ protected $searchableRelations = []; + /** + * Checks if category can be deleted + * + * @author [Dan Meltzer] [] + * @since [v5.0] + * @return bool + */ + public function isDeletable() + { + return (Gate::allows('delete', $this) + && ($this->itemCount() == 0)); + } + /** * Establishes the category -> accessories relationship * diff --git a/app/Models/Company.php b/app/Models/Company.php index a1094b60ea..c81655029e 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -5,6 +5,7 @@ use App\Models\Traits\Searchable; use App\Presenters\Presentable; use Auth; use DB; +use Illuminate\Support\Facades\Gate; use Watson\Validating\ValidatingTrait; /** @@ -84,7 +85,6 @@ final class Company extends SnipeModel } else { return $query->join('users as users_comp', 'users_comp.id', 'user_id')->where('users_comp.company_id', '=', $company_id); } - } public static function getIdFromInput($unescaped_input) @@ -143,6 +143,22 @@ final class Company extends SnipeModel Auth::user()->company_id == null); } + /** + * Checks if company can be deleted + * + * @author [Dan Meltzer] [] + * @since [v5.0] + * @return bool + */ + public function isDeletable() { + return Gate::allows('delete', $this) + && ($this->assets()->count() === 0) + && ($this->accessories()->count() === 0) + && ($this->consumables()->count() === 0) + && ($this->components()->count() === 0) + && ($this->users()->count() === 0); + } + public static function getIdForUser($unescaped_input) { if (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->isSuperUser()) { diff --git a/app/Models/Location.php b/app/Models/Location.php index 3b6f862e52..dd1a8c5a43 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -7,10 +7,11 @@ use App\Models\SnipeModel; use App\Models\Traits\Searchable; use App\Models\User; use App\Presenters\Presentable; +use DB; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\Gate; use Watson\Validating\ValidatingTrait; -use DB; class Location extends SnipeModel { @@ -86,6 +87,14 @@ class Location extends SnipeModel 'parent' => ['name'] ]; + public function isDeletable() + { + return Gate::allows('delete', $this) + && ($this->assignedAssets()->count()===0) + && ($this->assets()->count()===0) + && ($this->users()->count()===0); + } + public function users() { return $this->hasMany('\App\Models\User', 'location_id'); diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index c684c068d1..00ac8e7608 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -4,6 +4,7 @@ namespace App\Models; use App\Models\Traits\Searchable; use App\Presenters\Presentable; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\Gate; use Watson\Validating\ValidatingTrait; class Manufacturer extends SnipeModel @@ -49,22 +50,30 @@ class Manufacturer extends SnipeModel ]; use Searchable; - + /** * The attributes that should be included when searching the model. - * + * * @var array */ protected $searchableAttributes = ['name', 'created_at']; /** * The relations and their attributes that should be included when searching the model. - * + * * @var array */ - protected $searchableRelations = []; + protected $searchableRelations = []; + public function isDeletable() + { + return (Gate::allows('delete', $this) + && ($this->assets()->count() === 0) + && ($this->licenses()->count() === 0) + && ($this->consumables()->count() === 0) + && ($this->accessories()->count() === 0)); + } public function assets() { diff --git a/app/Notifications/AuditNotification.php b/app/Notifications/AuditNotification.php index 5629e82f33..900650e975 100644 --- a/app/Notifications/AuditNotification.php +++ b/app/Notifications/AuditNotification.php @@ -29,10 +29,9 @@ class AuditNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; if (Setting::getSettings()->slack_endpoint) { @@ -42,13 +41,13 @@ class AuditNotification extends Notification return $notifyBy; } - public function toSlack($notifiable) + public function toSlack() { return (new SlackMessage) ->success() ->content(class_basename(get_class($this->params['item'])) . " Audited") - ->attachment(function ($attachment) use ($notifiable) { + ->attachment(function ($attachment) { $item = $this->params['item']; $admin_user = $this->params['admin']; $fields = [ @@ -61,27 +60,4 @@ class AuditNotification extends Notification ->fields($fields); }); } - /** - * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage - */ - public function toMail($notifiable) - { - - } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/CheckinAccessoryNotification.php b/app/Notifications/CheckinAccessoryNotification.php index f6a8b19e96..2f6b5a5685 100644 --- a/app/Notifications/CheckinAccessoryNotification.php +++ b/app/Notifications/CheckinAccessoryNotification.php @@ -31,7 +31,6 @@ class CheckinAccessoryNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ public function via() @@ -65,14 +64,11 @@ class CheckinAccessoryNotification extends Notification $note = $this->note; $botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot' ; - $fields = [ 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>', 'By' => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', ]; - - return (new SlackMessage) ->content(':arrow_down: :keyboard: Accessory Checked In') ->from($botname) @@ -88,10 +84,8 @@ class CheckinAccessoryNotification extends Notification * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { - - return (new MailMessage)->markdown('notifications.markdown.checkin-accessory', [ 'item' => $this->item, @@ -102,17 +96,4 @@ class CheckinAccessoryNotification extends Notification ->subject('Accessory checked in'); } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/CheckinAssetNotification.php b/app/Notifications/CheckinAssetNotification.php index c203168e08..0b0c29d7b5 100644 --- a/app/Notifications/CheckinAssetNotification.php +++ b/app/Notifications/CheckinAssetNotification.php @@ -39,7 +39,6 @@ class CheckinAssetNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ public function via() @@ -53,7 +52,7 @@ class CheckinAssetNotification extends Notification } /** - * Only send checkin notifications to users if the category + * Only send checkin notifications to users if the category * has the corresponding checkbox checked. */ if ($this->item->checkin_email() && $this->target instanceof User && $this->target->email != '') @@ -78,7 +77,7 @@ class CheckinAssetNotification extends Notification trans('general.status') => $item->assetstatus->name, trans('general.location') => ($item->location) ? $item->location->name : '', ]; - + return (new SlackMessage) ->content(':arrow_down: :computer: Asset Checked In') ->from($botname) @@ -94,13 +93,10 @@ class CheckinAssetNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail() { - - $fields = []; // Check if the item has custom fields associated with it diff --git a/app/Notifications/CheckinLicenseSeatNotification.php b/app/Notifications/CheckinLicenseSeatNotification.php index f6459bae40..07d5455b13 100644 --- a/app/Notifications/CheckinLicenseSeatNotification.php +++ b/app/Notifications/CheckinLicenseSeatNotification.php @@ -35,10 +35,9 @@ class CheckinLicenseSeatNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; @@ -47,7 +46,7 @@ class CheckinLicenseSeatNotification extends Notification } /** - * Only send checkin notifications to users if the category + * Only send checkin notifications to users if the category * has the corresponding checkbox checked. */ if ($this->item->checkin_email() && $this->target instanceof User && $this->target->email != '') @@ -58,7 +57,7 @@ class CheckinLicenseSeatNotification extends Notification return $notifyBy; } - public function toSlack($notifiable) + public function toSlack() { $target = $this->target; @@ -90,7 +89,7 @@ class CheckinLicenseSeatNotification extends Notification * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { return (new MailMessage)->markdown('notifications.markdown.checkin-license', [ @@ -103,16 +102,4 @@ class CheckinLicenseSeatNotification extends Notification } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/CheckoutAccessoryNotification.php b/app/Notifications/CheckoutAccessoryNotification.php index 2e69856236..2c2001253d 100644 --- a/app/Notifications/CheckoutAccessoryNotification.php +++ b/app/Notifications/CheckoutAccessoryNotification.php @@ -25,7 +25,7 @@ class CheckoutAccessoryNotification extends Notification $this->note = $note; $this->target = $checkedOutTo; $this->acceptance = $acceptance; - + $this->settings = Setting::getSettings(); } @@ -33,10 +33,9 @@ class CheckoutAccessoryNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; @@ -52,7 +51,7 @@ class CheckoutAccessoryNotification extends Notification if ($this->target instanceof User && $this->target->email != '') { /** - * Send an email if the asset requires acceptance, + * Send an email if the asset requires acceptance, * so the user can accept or decline the asset */ if ($this->item->requireAcceptance()) { @@ -71,17 +70,15 @@ class CheckoutAccessoryNotification extends Notification */ if ($this->item->checkin_email()) { $notifyBy[1] = 'mail'; - } + } } return $notifyBy; } - public function toSlack($notifiable) + public function toSlack() { - - $target = $this->target; $admin = $this->admin; $item = $this->item; @@ -93,8 +90,6 @@ class CheckoutAccessoryNotification extends Notification 'By' => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', ]; - - return (new SlackMessage) ->content(':arrow_up: :keyboard: Accessory Checked Out') ->from($botname) @@ -107,12 +102,10 @@ class CheckoutAccessoryNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { - \Log::debug($this->item->getImageUrl()); $eula = $this->item->getEula(); $req_accept = $this->item->requireAcceptance(); @@ -132,17 +125,4 @@ class CheckoutAccessoryNotification extends Notification ->subject(trans('mail.Confirm_accessory_delivery')); } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/CheckoutAssetNotification.php b/app/Notifications/CheckoutAssetNotification.php index 8c93f08c54..ff759f68ef 100644 --- a/app/Notifications/CheckoutAssetNotification.php +++ b/app/Notifications/CheckoutAssetNotification.php @@ -49,7 +49,6 @@ class CheckoutAssetNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ public function via() @@ -68,7 +67,7 @@ class CheckoutAssetNotification extends Notification if ($this->target instanceof User && $this->target->email != '') { /** - * Send an email if the asset requires acceptance, + * Send an email if the asset requires acceptance, * so the user can accept or decline the asset */ if ($this->item->requireAcceptance()) { @@ -80,14 +79,14 @@ class CheckoutAssetNotification extends Notification */ if ($this->item->getEula()) { $notifyBy[1] = 'mail'; - } + } /** * Send an email if an email should be sent at checkin/checkout */ if ($this->item->checkin_email()) { $notifyBy[1] = 'mail'; - } + } } @@ -160,7 +159,6 @@ class CheckoutAssetNotification extends Notification return $message; - } } diff --git a/app/Notifications/CheckoutConsumableNotification.php b/app/Notifications/CheckoutConsumableNotification.php index a9785677cd..edf970789d 100644 --- a/app/Notifications/CheckoutConsumableNotification.php +++ b/app/Notifications/CheckoutConsumableNotification.php @@ -39,10 +39,9 @@ class CheckoutConsumableNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; @@ -56,7 +55,7 @@ class CheckoutConsumableNotification extends Notification if ($this->target instanceof User && $this->target->email != '') { /** - * Send an email if the asset requires acceptance, + * Send an email if the asset requires acceptance, * so the user can accept or decline the asset */ if ($this->item->requireAcceptance()) { @@ -68,7 +67,7 @@ class CheckoutConsumableNotification extends Notification */ if ($this->item->getEula()) { $notifyBy[1] = 'mail'; - } + } /** * Send an email if an email should be sent at checkin/checkout @@ -77,14 +76,14 @@ class CheckoutConsumableNotification extends Notification if ((method_exists($this->item, 'checkin_email')) && ($this->item->checkin_email())) { $notifyBy[1] = 'mail'; - } + } } return $notifyBy; } - public function toSlack($notifiable) + public function toSlack() { $target = $this->target; $admin = $this->admin; @@ -109,10 +108,9 @@ class CheckoutConsumableNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { \Log::debug($this->item->getImageUrl()); @@ -135,16 +133,4 @@ class CheckoutConsumableNotification extends Notification } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/CheckoutLicenseSeatNotification.php b/app/Notifications/CheckoutLicenseSeatNotification.php index fd21295210..3ec2c1f9ae 100644 --- a/app/Notifications/CheckoutLicenseSeatNotification.php +++ b/app/Notifications/CheckoutLicenseSeatNotification.php @@ -37,7 +37,6 @@ class CheckoutLicenseSeatNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ public function via() @@ -54,7 +53,7 @@ class CheckoutLicenseSeatNotification extends Notification if ($this->target instanceof User && $this->target->email != '') { /** - * Send an email if the asset requires acceptance, + * Send an email if the asset requires acceptance, * so the user can accept or decline the asset */ if ($this->item->requireAcceptance()) { @@ -66,23 +65,22 @@ class CheckoutLicenseSeatNotification extends Notification */ if ($this->item->getEula()) { $notifyBy[1] = 'mail'; - } + } /** * Send an email if an email should be sent at checkin/checkout */ if ($this->item->checkin_email()) { $notifyBy[1] = 'mail'; - } + } } - + return $notifyBy; } - public function toSlack($notifiable) + public function toSlack() { - $target = $this->target; $admin = $this->admin; $item = $this->item; @@ -106,10 +104,9 @@ class CheckoutLicenseSeatNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { $eula = method_exists($this->item, 'getEula') ? $this->item->getEula() : ''; @@ -131,16 +128,4 @@ class CheckoutLicenseSeatNotification extends Notification } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/CurrentInventory.php b/app/Notifications/CurrentInventory.php index 3948fe9c0d..d0161aa165 100644 --- a/app/Notifications/CurrentInventory.php +++ b/app/Notifications/CurrentInventory.php @@ -26,7 +26,7 @@ class CurrentInventory extends Notification * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { return ['mail']; } @@ -34,10 +34,9 @@ class CurrentInventory extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { $message = (new MailMessage)->markdown('notifications.markdown.user-inventory', [ @@ -49,17 +48,4 @@ class CurrentInventory extends Notification return $message; } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/ExpectedCheckinAdminNotification.php b/app/Notifications/ExpectedCheckinAdminNotification.php index 743e801d96..c90c2fa3e1 100644 --- a/app/Notifications/ExpectedCheckinAdminNotification.php +++ b/app/Notifications/ExpectedCheckinAdminNotification.php @@ -27,28 +27,21 @@ class ExpectedCheckinAdminNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; $notifyBy[]='mail'; return $notifyBy; } - public function toSlack($notifiable) - { - - } - /** * Get the mail representation of the notification. * - * @param mixed $asset * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($params) + public function toMail() { $message = (new MailMessage)->markdown('notifications.markdown.report-expected-checkins', @@ -62,16 +55,4 @@ class ExpectedCheckinAdminNotification extends Notification } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/ExpectedCheckinNotification.php b/app/Notifications/ExpectedCheckinNotification.php index 06d5589e90..e7262ae54e 100644 --- a/app/Notifications/ExpectedCheckinNotification.php +++ b/app/Notifications/ExpectedCheckinNotification.php @@ -28,10 +28,9 @@ class ExpectedCheckinNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; $item = $this->params['item']; @@ -40,18 +39,12 @@ class ExpectedCheckinNotification extends Notification return $notifyBy; } - public function toSlack($notifiable) - { - - } - /** * Get the mail representation of the notification. * - * @param mixed $asset * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($params) + public function toMail() { $formatted_due = Carbon::parse($this->params->expected_checkin)->format('D, M j, Y'); return (new MailMessage) @@ -63,20 +56,6 @@ class ExpectedCheckinNotification extends Notification ->line('Serial: '.$this->params->serial) ->line('Asset Tag: '.$this->params->asset_tag) ->action('View Your Assets', route('view-assets')); - - } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/ExpiringAssetsNotification.php b/app/Notifications/ExpiringAssetsNotification.php index d130d26e27..47d5509259 100644 --- a/app/Notifications/ExpiringAssetsNotification.php +++ b/app/Notifications/ExpiringAssetsNotification.php @@ -28,28 +28,22 @@ class ExpiringAssetsNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; $notifyBy[]='mail'; return $notifyBy; } - public function toSlack($notifiable) - { - - } - /** * Get the mail representation of the notification. * * @param mixed $asset * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($params) + public function toMail() { $message = (new MailMessage)->markdown('notifications.markdown.report-expiring-assets', @@ -64,16 +58,4 @@ class ExpiringAssetsNotification extends Notification } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/ExpiringLicenseNotification.php b/app/Notifications/ExpiringLicenseNotification.php index fce8ba23ef..5ca1e93cf6 100644 --- a/app/Notifications/ExpiringLicenseNotification.php +++ b/app/Notifications/ExpiringLicenseNotification.php @@ -31,25 +31,20 @@ class ExpiringLicenseNotification extends Notification * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy = []; $notifyBy[]='mail'; return $notifyBy; } - public function toSlack($notifiable) - { - - } - /** * Get the mail representation of the notification. * * @param mixed $asset * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($params) + public function toMail() { $message = (new MailMessage)->markdown('notifications.markdown.report-expiring-licenses', @@ -64,16 +59,4 @@ class ExpiringLicenseNotification extends Notification } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/FirstAdminNotification.php b/app/Notifications/FirstAdminNotification.php index 951e24e72b..153aff4aec 100644 --- a/app/Notifications/FirstAdminNotification.php +++ b/app/Notifications/FirstAdminNotification.php @@ -30,10 +30,9 @@ class FirstAdminNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { return ['mail']; } @@ -41,26 +40,13 @@ class FirstAdminNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { return (new MailMessage) ->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ])) ->markdown('notifications.FirstAdmin', $this->_data); } - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/InventoryAlert.php b/app/Notifications/InventoryAlert.php index 31b61a13ae..ff88b548c0 100644 --- a/app/Notifications/InventoryAlert.php +++ b/app/Notifications/InventoryAlert.php @@ -28,27 +28,21 @@ class InventoryAlert extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { $notifyBy[] = 'mail'; return $notifyBy; } - public function toSlack($notifiable) - { - } - /** * Get the mail representation of the notification. * - * @param mixed $asset * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($params) + public function toMail() { $message = (new MailMessage)->markdown( 'notifications.markdown.report-low-inventory', @@ -61,17 +55,4 @@ class InventoryAlert extends Notification return $message; } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/MailTest.php b/app/Notifications/MailTest.php index 1e84fab8e9..65a6c63b77 100644 --- a/app/Notifications/MailTest.php +++ b/app/Notifications/MailTest.php @@ -24,10 +24,9 @@ class MailTest extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { return ['mail']; } @@ -35,26 +34,12 @@ class MailTest extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { return (new MailMessage) ->subject(trans('mail.test_email')) ->markdown('notifications.Test'); } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/RequestAssetCancelation.php b/app/Notifications/RequestAssetCancelation.php index 21c565c632..d50aea3529 100644 --- a/app/Notifications/RequestAssetCancelation.php +++ b/app/Notifications/RequestAssetCancelation.php @@ -2,6 +2,7 @@ namespace App\Notifications; +use App\Helpers\Helper; use App\Models\Setting; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; @@ -27,7 +28,7 @@ class RequestAssetCancelation extends Notification $this->last_checkout = ''; $this->item_quantity = $params['item_quantity']; $this->expected_checkin = ''; - $this->requested_date = \App\Helpers\Helper::getFormattedDateObject($params['requested_date'], 'datetime', + $this->requested_date = Helper::getFormattedDateObject($params['requested_date'], 'datetime', false); $this->settings = Setting::getSettings(); @@ -36,16 +37,14 @@ class RequestAssetCancelation extends Notification } if ($this->item->last_checkout) { - $this->last_checkout = \App\Helpers\Helper::getFormattedDateObject($this->item->last_checkout, 'date', + $this->last_checkout = Helper::getFormattedDateObject($this->item->last_checkout, 'date', false); } if ($this->item->expected_checkin) { - $this->expected_checkin = \App\Helpers\Helper::getFormattedDateObject($this->item->expected_checkin, 'date', + $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'date', false); } - - } /** @@ -72,8 +71,6 @@ class RequestAssetCancelation extends Notification public function toSlack() { - - $target = $this->target; $item = $this->item; $note = $this->note; @@ -130,8 +127,6 @@ class RequestAssetCancelation extends Notification return $message; - - } } diff --git a/app/Notifications/RequestAssetNotification.php b/app/Notifications/RequestAssetNotification.php index eac2cef22f..8c0c7d8505 100644 --- a/app/Notifications/RequestAssetNotification.php +++ b/app/Notifications/RequestAssetNotification.php @@ -2,6 +2,7 @@ namespace App\Notifications; +use App\Helpers\Helper; use App\Models\Setting; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; @@ -28,7 +29,7 @@ class RequestAssetNotification extends Notification $this->note = ''; $this->last_checkout = ''; $this->expected_checkin = ''; - $this->requested_date = \App\Helpers\Helper::getFormattedDateObject($params['requested_date'], 'datetime', + $this->requested_date = Helper::getFormattedDateObject($params['requested_date'], 'datetime', false); $this->settings = Setting::getSettings(); @@ -37,12 +38,12 @@ class RequestAssetNotification extends Notification } if ($this->item->last_checkout) { - $this->last_checkout = \App\Helpers\Helper::getFormattedDateObject($this->item->last_checkout, 'date', + $this->last_checkout = Helper::getFormattedDateObject($this->item->last_checkout, 'date', false); } if ($this->item->expected_checkin) { - $this->expected_checkin = \App\Helpers\Helper::getFormattedDateObject($this->item->expected_checkin, 'date', + $this->expected_checkin = Helper::getFormattedDateObject($this->item->expected_checkin, 'date', false); } @@ -73,8 +74,6 @@ class RequestAssetNotification extends Notification public function toSlack() { - - $target = $this->target; $qty = $this->item_quantity; $item = $this->item; @@ -98,7 +97,6 @@ class RequestAssetNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail() @@ -127,8 +125,6 @@ class RequestAssetNotification extends Notification return $message; - - } } diff --git a/app/Notifications/SendUpcomingAuditNotification.php b/app/Notifications/SendUpcomingAuditNotification.php index 0aaf11cda5..a6863ea8e3 100644 --- a/app/Notifications/SendUpcomingAuditNotification.php +++ b/app/Notifications/SendUpcomingAuditNotification.php @@ -26,10 +26,9 @@ class SendUpcomingAuditNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { return $notifyBy = ['mail']; } @@ -37,10 +36,9 @@ class SendUpcomingAuditNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { $message = (new MailMessage)->markdown('notifications.markdown.upcoming-audits', [ @@ -51,17 +49,4 @@ class SendUpcomingAuditNotification extends Notification return $message; } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/SlackTest.php b/app/Notifications/SlackTest.php index 1d18be86a1..99d37761b8 100644 --- a/app/Notifications/SlackTest.php +++ b/app/Notifications/SlackTest.php @@ -32,26 +32,13 @@ class SlackTest extends Notification return ['slack']; } - /** - * Get the mail representation of the notification. - * - * @param mixed $notifiable - * @return \Illuminate\Notifications\Messages\MailMessage - */ - public function toMail($notifiable) - { - return [ - // - ]; - } - /** * Get the Slack representation of the notification. * * @param mixed $notifiable * @return SlackMessage */ - public function toSlack($notifiable) + public function toSlack() { $settings = Setting::getSettings(); return (new SlackMessage) @@ -61,17 +48,4 @@ class SlackTest extends Notification ->content('Oh hai! Looks like your Slack integration with Snipe-IT is working!'); } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Notifications/WelcomeNotification.php b/app/Notifications/WelcomeNotification.php index 0fc3377708..9a98a97734 100644 --- a/app/Notifications/WelcomeNotification.php +++ b/app/Notifications/WelcomeNotification.php @@ -30,10 +30,9 @@ class WelcomeNotification extends Notification /** * Get the notification's delivery channels. * - * @param mixed $notifiable * @return array */ - public function via($notifiable) + public function via() { return ['mail']; } @@ -41,26 +40,12 @@ class WelcomeNotification extends Notification /** * Get the mail representation of the notification. * - * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ - public function toMail($notifiable) + public function toMail() { return (new MailMessage) ->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ])) ->markdown('notifications.Welcome', $this->_data); } - - /** - * Get the array representation of the notification. - * - * @param mixed $notifiable - * @return array - */ - public function toArray($notifiable) - { - return [ - // - ]; - } } diff --git a/app/Policies/SnipePermissionsPolicy.php b/app/Policies/SnipePermissionsPolicy.php index e17f4f68e5..435828fd14 100644 --- a/app/Policies/SnipePermissionsPolicy.php +++ b/app/Policies/SnipePermissionsPolicy.php @@ -91,7 +91,11 @@ abstract class SnipePermissionsPolicy */ public function delete(User $user, $item = null) { - return $user->hasAccess($this->columnName().'.delete'); + $itemConditional = true; + if ($item) { + $itemConditional = empty($item->deleted_at); + } + return $itemConditional && $user->hasAccess($this->columnName().'.delete'); } /** diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php index 248a875822..16c49b4420 100644 --- a/app/Presenters/CategoryPresenter.php +++ b/app/Presenters/CategoryPresenter.php @@ -43,52 +43,27 @@ class CategoryPresenter extends Presenter "sortable" => true, "title" => trans('general.type'), "visible" => true - ], [ - "field" => "assets_count", + ],[ + "field" => "item_count", "searchable" => false, "sortable" => true, - "title" => trans('general.assets'), + "title" => trans('general.qty'), "visible" => true - ], [ - "field" => "accessories_count", - "searchable" => false, - "sortable" => true, - "title" => trans('general.accessories'), - "visible" => true - ], [ - "field" => "consumables_count", - "searchable" => false, - "sortable" => true, - "title" => trans('general.consumables'), - "visible" => true - ], [ - "field" => "components_count", - "searchable" => false, - "sortable" => true, - "title" => trans('general.components'), - "visible" => true - ], [ - "field" => "licenses_count", - "searchable" => false, - "sortable" => true, - "title" => trans('general.licenses'), - "visible" => true - ], [ + ],[ "field" => "eula", "searchable" => false, "sortable" => false, "title" => trans('admin/categories/table.eula_text'), "visible" => false, "formatter" => 'trueFalseFormatter', - ], [ + ],[ "field" => "require_acceptance", "searchable" => false, "sortable" => true, "title" => trans('admin/categories/table.require_acceptance'), "visible" => true, "formatter" => 'trueFalseFormatter', - ], - [ + ],[ "field" => "actions", "searchable" => false, "sortable" => false, diff --git a/resources/assets/js/snipeit_modals.js b/resources/assets/js/snipeit_modals.js index 6866802b6e..f1301b03f3 100644 --- a/resources/assets/js/snipeit_modals.js +++ b/resources/assets/js/snipeit_modals.js @@ -11,7 +11,7 @@ Create a Button looking like this: - New + New If you don't have access to Blade commands (like {{ and }}, etc), you can hard-code a URL as the 'href' diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 0399a53dab..c4abc19793 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -211,7 +211,7 @@ 'unknown_admin' => 'Unknown Admin', 'username_format' => 'Username Format', 'update' => 'Update', - 'upload_filetypes_help' => 'Allowed filetypes are png, gif, jpg, jpeg, doc, docx, pdf, xls, txt, lic, xml, zip, rtf and rar. Max upload size allowed is :size.', + 'upload_filetypes_help' => 'Allowed filetypes are png, gif, jpg, jpeg, doc, docx, pdf, xls, xlsx, txt, lic, xml, zip, rtf and rar. Max upload size allowed is :size.', 'uploaded' => 'Uploaded', 'user' => 'User', 'accepted' => 'accepted', diff --git a/resources/views/kits/edit.blade.php b/resources/views/kits/edit.blade.php index 791de26d88..22c5845579 100644 --- a/resources/views/kits/edit.blade.php +++ b/resources/views/kits/edit.blade.php @@ -39,7 +39,7 @@ "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> - Append + Append @@ -73,7 +73,7 @@ "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> - Append{{-- TODO: trans --}} + Append{{-- TODO: trans --}} @@ -107,7 +107,7 @@ "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> - Append{{-- TODO: trans --}} + Append{{-- TODO: trans --}} @@ -141,7 +141,7 @@ "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> - Append{{-- TODO: trans --}} + Append{{-- TODO: trans --}} diff --git a/resources/views/modals/kit-accessory.blade.php b/resources/views/modals/kit-accessory.blade.php index 61d004f4f6..6e5fd6807c 100644 --- a/resources/views/modals/kit-accessory.blade.php +++ b/resources/views/modals/kit-accessory.blade.php @@ -7,11 +7,11 @@