mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
commit
850bfc40d4
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -1 +1,3 @@
|
|||
* text=auto
|
||||
public/js/** binary
|
||||
public/css/** binary
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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')));
|
||||
|
|
|
@ -137,24 +137,13 @@ class CompaniesController extends Controller
|
|||
$company = Company::findOrFail($id);
|
||||
$this->authorize('delete', $company);
|
||||
|
||||
try {
|
||||
if ( !$company->isDeletable() ) {
|
||||
return response()
|
||||
->json(Helper::formatStandardApiResponse('error', null, trans('admin/companies/message.assoc_users')));
|
||||
}
|
||||
$company->delete();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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')));
|
||||
|
|
|
@ -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')));
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
return view('hardware/index')->with('company', $company);
|
||||
}
|
||||
|
||||
|
|
|
@ -206,11 +206,13 @@ class BulkAssetsController extends Controller
|
|||
|
||||
$asset_ids = array_filter($request->get('selected_assets'));
|
||||
|
||||
if(request('checkout_to_type') =='asset') {
|
||||
foreach ($asset_ids as $asset_id) {
|
||||
if ($target->id == $asset_id && request('checkout_to_type') =='asset') {
|
||||
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");
|
||||
if (($request->filled('checkout_at')) && ($request->get('checkout_at')!= date("Y-m-d"))) {
|
||||
$checkout_at = e($request->get('checkout_at'));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -142,8 +142,10 @@ final class CompaniesController extends Controller
|
|||
}
|
||||
|
||||
$this->authorize('delete', $company);
|
||||
|
||||
try {
|
||||
if(!$company->isDeletable()) {
|
||||
return redirect()->route('companies.index')
|
||||
->with('error', trans('admin/companies/message.assoc_users'));
|
||||
}
|
||||
|
||||
if ($company->image) {
|
||||
try {
|
||||
|
@ -156,18 +158,6 @@ final class CompaniesController extends Controller
|
|||
$company->delete();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public function show($id) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
if($type == "statuslabel") {
|
||||
$view->with('statuslabel_types', Helper::statusTypeList());
|
||||
}
|
||||
|
||||
function statuslabel() {
|
||||
return view('modals.statuslabel')->with('statuslabel_types', Helper::statusTypeList());
|
||||
if(in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) {
|
||||
$view->with('kitId', $itemId);
|
||||
}
|
||||
|
||||
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');
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,10 +42,9 @@ 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];
|
||||
|
@ -57,7 +53,6 @@ class BulkUsersController extends Controller
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return redirect()->back()->with('success', trans('admin/users/message.password_resets_sent'));
|
||||
|
||||
}
|
||||
|
|
|
@ -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,11 +221,11 @@ 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.');
|
||||
} 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();
|
||||
|
@ -235,11 +235,6 @@ class UsersController extends Controller
|
|||
$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')));
|
||||
}
|
||||
|
||||
|
||||
// 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'));
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
'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!='')) ? true : false,
|
||||
'restore' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at!='')),
|
||||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
|
|
@ -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,
|
||||
];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
];
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -85,6 +86,19 @@ class Category extends SnipeModel
|
|||
protected $searchableRelations = [];
|
||||
|
||||
|
||||
/**
|
||||
* Checks if category can be deleted
|
||||
*
|
||||
* @author [Dan Meltzer] [<dmeltzer.devel@gmail.com>]
|
||||
* @since [v5.0]
|
||||
* @return bool
|
||||
*/
|
||||
public function isDeletable()
|
||||
{
|
||||
return (Gate::allows('delete', $this)
|
||||
&& ($this->itemCount() == 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes the category -> accessories relationship
|
||||
*
|
||||
|
|
|
@ -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] [<dmeltzer.devel@gmail.com>]
|
||||
* @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()) {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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
|
||||
|
@ -65,6 +66,14 @@ class Manufacturer extends SnipeModel
|
|||
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()
|
||||
{
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ class CheckinAssetNotification extends Notification
|
|||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
|
@ -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
|
||||
|
|
|
@ -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 = [];
|
||||
|
||||
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 = [];
|
||||
|
@ -78,10 +77,8 @@ class CheckoutAccessoryNotification extends Notification
|
|||
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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ class CheckoutAssetNotification extends Notification
|
|||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
|
@ -160,7 +159,6 @@ class CheckoutAssetNotification extends Notification
|
|||
|
||||
return $message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 = [];
|
||||
|
||||
|
@ -84,7 +83,7 @@ class CheckoutConsumableNotification extends Notification
|
|||
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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ class CheckoutLicenseSeatNotification extends Notification
|
|||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via()
|
||||
|
@ -80,9 +79,8 @@ class CheckoutLicenseSeatNotification extends Notification
|
|||
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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,34 +44,10 @@ class CategoryPresenter extends Presenter
|
|||
"title" => trans('general.type'),
|
||||
"visible" => true
|
||||
],[
|
||||
"field" => "assets_count",
|
||||
"field" => "item_count",
|
||||
"searchable" => false,
|
||||
"sortable" => true,
|
||||
"title" => trans('general.assets'),
|
||||
"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'),
|
||||
"title" => trans('general.qty'),
|
||||
"visible" => true
|
||||
],[
|
||||
"field" => "eula",
|
||||
|
@ -87,8 +63,7 @@ class CategoryPresenter extends Presenter
|
|||
"title" => trans('admin/categories/table.require_acceptance'),
|
||||
"visible" => true,
|
||||
"formatter" => 'trueFalseFormatter',
|
||||
],
|
||||
[
|
||||
],[
|
||||
"field" => "actions",
|
||||
"searchable" => false,
|
||||
"sortable" => false,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
Create a Button looking like this:
|
||||
|
||||
<a href='{{ route('modal.user') }}' data-toggle="modal" data-target="#createModal" data-select='assigned_to' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'user') }}' data-toggle="modal" data-target="#createModal" data-select='assigned_to' class="btn btn-sm btn-primary">New</a>
|
||||
|
||||
If you don't have access to Blade commands (like {{ and }}, etc), you can hard-code a URL as the 'href'
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
||||
}'>
|
||||
</table>
|
||||
<a href="{{ route('modal.kit.model', ['kit' => $item->id]) }}" data-refresh="kitModelsTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append</a>
|
||||
<a href="{{ route('modal.show', ['type' => 'kit-model', 'itemId' => $item->id]) }}" data-refresh="kitModelsTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append</a>
|
||||
</div>
|
||||
</div> <!--.box-body-->
|
||||
</div> <!-- /.box.box-default-->
|
||||
|
@ -73,7 +73,7 @@
|
|||
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
||||
}'>
|
||||
</table>
|
||||
<a href="{{ route('modal.kit.license', ['kit' => $item->id]) }}" data-refresh="kitLicensesTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append{{-- TODO: trans --}}</a>
|
||||
<a href="{{ route('modal.show', [ 'type' => 'kit-license', 'itemId' => $item->id]) }}" data-refresh="kitLicensesTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append{{-- TODO: trans --}}</a>
|
||||
</div>
|
||||
</div> <!--.box-body-->
|
||||
</div> <!-- /.box.box-default-->
|
||||
|
@ -107,7 +107,7 @@
|
|||
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
||||
}'>
|
||||
</table>
|
||||
<a href="{{ route('modal.kit.consumable', ['kit' => $item->id]) }}" data-refresh="kitConsumablesTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append{{-- TODO: trans --}}</a>
|
||||
<a href="{{ route('modal.show', ['type' => 'kit-consumable', 'itemId' => $item->id]) }}" data-refresh="kitConsumablesTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append{{-- TODO: trans --}}</a>
|
||||
</div>
|
||||
</div> <!--.box-body-->
|
||||
</div> <!-- /.box.box-default-->
|
||||
|
@ -141,7 +141,7 @@
|
|||
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
|
||||
}'>
|
||||
</table>
|
||||
<a href="{{ route('modal.kit.accessory', ['kit' => $item->id]) }}" data-refresh="kitAccessoriesTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append{{-- TODO: trans --}}</a>
|
||||
<a href="{{ route('modal.show', ['type' => 'kit-accessory', 'itemId' => $item->id]) }}" data-refresh="kitAccessoriesTable" data-toggle="modal" data-target="#createModal" class="btn btn-primary pull-right"><i class="fa fa-plus icon-white"></i> Append{{-- TODO: trans --}}</a>
|
||||
</div>
|
||||
</div> <!--.box-body-->
|
||||
</div> <!-- /.box.box-default-->
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<h4 class="modal-title">Append accessory{{-- TODO: trans --}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('api.kits.accessories.store', ['kit_id' => request('kit')]) }}" onsubmit="return false">
|
||||
<form action="{{ route('api.kits.accessories.store', $kitId) }}" onsubmit="return false">
|
||||
{{ csrf_field() }}
|
||||
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<h4 class="modal-title">Append consumable{{-- TODO: trans --}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('api.kits.consumables.store', ['kit_id' => request('kit')]) }}" onsubmit="return false">
|
||||
<form action="{{ route('api.kits.consumables.store', $kitId) }}" onsubmit="return false">
|
||||
{{ csrf_field() }}
|
||||
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<h4 class="modal-title">Append license{{-- TODO: trans --}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('api.kits.licenses.store', ['kit_id' => request('kit')]) }}" onsubmit="return false">
|
||||
<form action="{{ route('api.kits.licenses.store', $kitId) }}" onsubmit="return false">
|
||||
{{ csrf_field() }}
|
||||
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<h4 class="modal-title">Append model{{-- TODO: trans --}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form action="{{ route('api.kits.models.store', ['kit_id' => request('kit')]) }}" onsubmit="return false">
|
||||
<form action="{{ route('api.kits.models.store', $kitId) }}" onsubmit="return false">
|
||||
{{ csrf_field() }}
|
||||
<div class="alert alert-danger" id="modal_error_msg" style="display:none">
|
||||
</div>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<label class="btn btn-default">
|
||||
{{ trans('button.select_file') }}
|
||||
<input type="file" name="file[]" multiple="true" class="js-uploadFile" id="uploadFile" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/*,.csv,.zip,.rar,.doc,.docx,.xls,.xml,.lic,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/plain,.pdf,application/rtf" style="display:none">
|
||||
<input type="file" name="file[]" multiple="true" class="js-uploadFile" id="uploadFile" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/*,.csv,.zip,.rar,.doc,.docx,.xls,.xlsx,.xml,.lic,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/plain,.pdf,application/rtf" style="display:none">
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\Category::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.category',['category_type' => isset($category_type) ? $category_type : 'assets' ]) }}' data-toggle="modal" data-target="#createModal" data-select='category_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show',['type' => 'category', 'category_type' => isset($category_type) ? $category_type : 'assets' ]) }}' data-toggle="modal" data-target="#createModal" data-select='category_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\PredefinedKit::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
{{-- <a href='{{ route('modal.kit') }}' data-toggle="modal" data-target="#createModal" data-select='kit_id_select' class="btn btn-sm btn-default">New</a> --}}
|
||||
{{-- <a href='{{ route('modal.show, 'kit') }}' data-toggle="modal" data-target="#createModal" data-select='kit_id_select' class="btn btn-sm btn-default">New</a> --}}
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\Location::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.location') }}' data-toggle="modal" data-target="#createModal" data-select='{{ $fieldname }}_location_select' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'location') }}' data-toggle="modal" data-target="#createModal" data-select='{{ $fieldname }}_location_select' class="btn btn-sm btn-primary">New</a>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\Manufacturer::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.manufacturer') }}' data-toggle="modal" data-target="#createModal" data-select='manufacturer_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'manufacturer') }}' data-toggle="modal" data-target="#createModal" data-select='manufacturer_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\AssetModel::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.model') }}' data-toggle="modal" data-target="#createModal" data-select='model_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'model') }}' data-toggle="modal" data-target="#createModal" data-select='model_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
<span class="mac_spinner" style="padding-left: 10px; color: green; display:none; width: 30px;">
|
||||
<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>
|
||||
</span>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="col-md-2 col-sm-2 text-left">
|
||||
|
||||
@can('create', \App\Models\Statuslabel::class)
|
||||
<a href='{{ route('modal.statuslabel') }}' data-toggle="modal" data-target="#createModal" data-select='status_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'statuslabel') }}' data-toggle="modal" data-target="#createModal" data-select='status_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
@endcan
|
||||
|
||||
<span class="status_spinner" style="padding-left: 10px; color: green; display:none; width: 30px;"><i class="fa fa-spinner fa-spin" aria-hidden="true"></i> </span>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\Supplier::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.supplier') }}' data-toggle="modal" data-target="#createModal" data-select='supplier_select' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'supplier') }}' data-toggle="modal" data-target="#createModal" data-select='supplier_select' class="btn btn-sm btn-primary">New</a>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
{!! $errors->first('supplier_id', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
<a href='{{ route('modal.supplier') }}' data-toggle="modal" data-target="#createModal" data-dependency="supplier" data-select='supplier_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'supplier') }}' data-toggle="modal" data-target="#createModal" data-dependency="supplier" data-select='supplier_select_id' class="btn btn-sm btn-primary">New</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<div class="col-md-1 col-sm-1 text-left">
|
||||
@can('create', \App\Models\User::class)
|
||||
@if ((!isset($hide_new)) || ($hide_new!='true'))
|
||||
<a href='{{ route('modal.user') }}' data-toggle="modal" data-target="#createModal" data-select='assigned_user_select' class="btn btn-sm btn-primary">New</a>
|
||||
<a href='{{ route('modal.show', 'user') }}' data-toggle="modal" data-target="#createModal" data-select='assigned_user_select' class="btn btn-sm btn-primary">New</a>
|
||||
@endif
|
||||
@endcan
|
||||
</div>
|
||||
|
|
|
@ -80,17 +80,7 @@ Route::group(['middleware' => 'auth'], function () {
|
|||
*/
|
||||
|
||||
Route::group(['middleware' => 'auth','prefix' => 'modals'], function () {
|
||||
Route::get('location',['as' => 'modal.location','uses' => 'ModalController@location']);
|
||||
Route::get('category',['as' => 'modal.category','uses' => 'ModalController@category']);
|
||||
Route::get('manufacturer',['as' => 'modal.manufacturer','uses' => 'ModalController@manufacturer']);
|
||||
Route::get('model',['as' => 'modal.model','uses' => 'ModalController@model']);
|
||||
Route::get('statuslabel',['as' => 'modal.statuslabel','uses' => 'ModalController@statuslabel']);
|
||||
Route::get('supplier',['as' => 'modal.supplier','uses' => 'ModalController@supplier']);
|
||||
Route::get('user',['as' => 'modal.user','uses' => 'ModalController@user']);
|
||||
Route::get('kit-model',['as' => 'modal.kit.model','uses' => 'ModalController@kitModel']);
|
||||
Route::get('kit-license',['as' => 'modal.kit.license','uses' => 'ModalController@kitLicense']);
|
||||
Route::get('kit-consumable',['as' => 'modal.kit.consumable','uses' => 'ModalController@kitConsumable']);
|
||||
Route::get('kit-accessory',['as' => 'modal.kit.accessory','uses' => 'ModalController@kitAccessory']);
|
||||
Route::get('{type}/{itemId?}',['as' => 'modal.show', 'uses' => 'ModalController@show']);
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue