Merge pull request #8079 from dmeltzer/misc-fixes

Misc fixes
This commit is contained in:
snipe 2020-05-26 19:50:39 -07:00 committed by GitHub
commit 850bfc40d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
82 changed files with 339 additions and 717 deletions

4
.gitattributes vendored
View file

@ -1 +1,3 @@
* text=auto * text=auto
public/js/** binary
public/css/** binary

View file

@ -606,38 +606,32 @@ class Helper
$extension = substr(strrchr($filename,'.'),1); $extension = substr(strrchr($filename,'.'),1);
if ($extension) { $allowedExtensionMap = [
switch ($extension) { // Images
case 'jpg': 'jpg' => 'fa fa-file-image-o',
case 'jpeg': 'jpeg' => 'fa fa-file-image-o',
case 'gif': 'gif' => 'fa fa-file-image-o',
case 'png': 'png' => 'fa fa-file-image-o',
return "fa fa-file-image-o"; // word
break; 'doc' => 'fa fa-file-word-o',
case 'doc': 'docx' => 'fa fa-file-word-o',
case 'docx': // Excel
return "fa fa-file-word-o"; 'xls' => 'fa fa-file-excel-o',
break; 'xlsx' => 'fa fa-file-excel-o',
case 'xls': // archive
case 'xlsx': 'zip' => 'fa fa-file-archive-o',
return "fa fa-file-excel-o"; 'rar' => 'fa fa-file-archive-o',
break; //Text
case 'zip': 'txt' => 'fa fa-file-text-o',
case 'rar': 'rtf' => 'fa fa-file-text-o',
return "fa fa-file-archive-o"; 'xml' => 'fa fa-file-text-o',
break; // Misc
case 'pdf': 'pdf' => 'fa fa-file-pdf-o',
return "fa fa-file-pdf-o"; 'lic' => 'fa fa-file-floppy-o',
break; ];
case 'txt':
return "fa fa-file-text-o"; if ($extension && array_key_exists($extension, $allowedExtensionMap)) {
break; return $allowedExtensionMap[$extension];
case 'lic':
return "fa fa-floppy-o";
break;
default:
return "fa fa-file-o";
}
} }
return "fa fa-file-o"; return "fa fa-file-o";
} }

View file

@ -120,16 +120,12 @@ class CategoriesController extends Controller
public function destroy($id) public function destroy($id)
{ {
$this->authorize('delete', Category::class); $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) { if (!$category->isDeletable()) {
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>'model']))); return response()->json(
} elseif ($category->accessories_count > 0) { Helper::formatStandardApiResponse('error', null, trans('admin/categories/message.assoc_items', ['asset_type'=>$category->category_type]))
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'])));
} }
$category->delete(); $category->delete();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/categories/message.delete.success'))); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/categories/message.delete.success')));

View file

@ -48,7 +48,7 @@ class CompaniesController extends Controller
// Check to make sure the limit is not higher than the max allowed // 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'); ((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'; $order = $request->input('order') === 'asc' ? 'asc' : 'desc';
$sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at'; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'created_at';
$companies->orderBy($sort, $order); $companies->orderBy($sort, $order);
@ -133,28 +133,17 @@ class CompaniesController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
$this->authorize('delete', Company::class); $this->authorize('delete', Company::class);
$company = Company::findOrFail($id); $company = Company::findOrFail($id);
$this->authorize('delete', $company); $this->authorize('delete', $company);
try { if ( !$company->isDeletable() ) {
$company->delete();
return response() 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'))); ->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')));
} }
/** /**

View file

@ -179,6 +179,10 @@ class LocationsController extends Controller
{ {
$this->authorize('delete', Location::class); $this->authorize('delete', Location::class);
$location = Location::findOrFail($id); $location = Location::findOrFail($id);
if(!$location->isDeletable()) {
return response()
->json(Helper::formatStandardApiResponse('error', null, trans('admin/companies/message.assoc_users')));
}
$this->authorize('delete', $location); $this->authorize('delete', $location);
$location->delete(); $location->delete();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/locations/message.delete.success'))); return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/locations/message.delete.success')));
@ -259,4 +263,4 @@ class LocationsController extends Controller
} }
} }

View file

@ -125,15 +125,15 @@ class ManufacturersController extends Controller
{ {
$this->authorize('delete', Manufacturer::class); $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); $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(); $manufacturer->delete();
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/manufacturers/message.delete.success'))); 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')));

View file

@ -55,14 +55,14 @@ class AssetCheckinController extends Controller
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); 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); $this->authorize('checkin', $asset);
if ($asset->assignedType() == Asset::USER) { if ($asset->assignedType() == Asset::USER) {
$user = $asset->assignedTo; $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->expected_checkin = null;
$asset->last_checkout = null; $asset->last_checkout = null;
@ -89,7 +89,6 @@ class AssetCheckinController extends Controller
// Was the asset updated? // Was the asset updated?
if ($asset->save()) { if ($asset->save()) {
event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at)); event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at));
if ((isset($user)) && ($backto =='user')) { if ((isset($user)) && ($backto =='user')) {

View file

@ -63,11 +63,7 @@ class AssetsController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
$this->authorize('index', Asset::class); $this->authorize('index', Asset::class);
if ($request->filled('company_id')) { $company = Company::find($request->input('company_id'));
$company = Company::find($request->input('company_id'));
} else {
$company = null;
}
return view('hardware/index')->with('company', $company); return view('hardware/index')->with('company', $company);
} }

View file

@ -206,9 +206,11 @@ class BulkAssetsController extends Controller
$asset_ids = array_filter($request->get('selected_assets')); $asset_ids = array_filter($request->get('selected_assets'));
foreach ($asset_ids as $asset_id) { if(request('checkout_to_type') =='asset') {
if ($target->id == $asset_id && request('checkout_to_type') =='asset') { foreach ($asset_ids as $asset_id) {
return redirect()->back()->with('error', 'You cannot check an asset out to itself.'); 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"); $checkout_at = date("Y-m-d H:i:s");

View file

@ -159,18 +159,12 @@ class CategoriesController extends Controller
{ {
$this->authorize('delete', Category::class); $this->authorize('delete', Category::class);
// Check if the category exists // 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')); return redirect()->route('categories.index')->with('error', trans('admin/categories/message.not_found'));
} }
if ($category->models_count > 0) { if (!$category->isDeletable()) {
return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'model'])); return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=> $category->category_type ]));
} 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']));
} }
Storage::disk('public')->delete('categories'.'/'.$category->image); Storage::disk('public')->delete('categories'.'/'.$category->image);

View file

@ -113,7 +113,7 @@ final class CompaniesController extends Controller
$company->name = $request->input('name'); $company->name = $request->input('name');
$company = $request->handleImages($company,600, public_path().'/uploads/companies'); $company = $request->handleImages($company,600, public_path().'/uploads/companies');
@ -140,34 +140,24 @@ final class CompaniesController extends Controller
return redirect()->route('companies.index') return redirect()->route('companies.index')
->with('error', trans('admin/companies/message.not_found')); ->with('error', trans('admin/companies/message.not_found'));
} }
$this->authorize('delete', $company); $this->authorize('delete', $company);
if(!$company->isDeletable()) {
try {
if ($company->image) {
try {
Storage::disk('public')->delete('companies'.'/'.$company->image);
} catch (\Exception $e) {
\Log::debug($e);
}
}
$company->delete();
return redirect()->route('companies.index') 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')); ->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) { public function show($id) {

View file

@ -28,18 +28,16 @@ class LicenseFilesController extends Controller
public function store(AssetFileRequest $request, $licenseId = null) public function store(AssetFileRequest $request, $licenseId = null)
{ {
$license = License::find($licenseId); $license = License::find($licenseId);
// the license is valid
$destinationPath = config('app.private_uploads').'/licenses';
if (isset($license->id)) { if (isset($license->id)) {
$this->authorize('update', $license); $this->authorize('update', $license);
if (Request::hasFile('file')) { if ($request->hasFile('file')) {
if (!Storage::exists('private_uploads/licenses')) Storage::makeDirectory('private_uploads/licenses', 775); if (!Storage::exists('private_uploads/licenses')) Storage::makeDirectory('private_uploads/licenses', 775);
$upload_success = false; $upload_success = false;
foreach (Input::file('file') as $file) { foreach ($request->file('file') as $file) {
$extension = $file->getClientOriginalExtension(); $extension = $file->getClientOriginalExtension();
$file_name = 'license-'.$license->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension; $file_name = 'license-'.$license->id.'-'.str_random(8).'-'.str_slug(basename($file->getClientOriginalName(), '.'.$extension)).'.'.$extension;

View file

@ -171,18 +171,14 @@ class LocationsController extends Controller
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found')); 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')); return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users'));
} elseif ($location->children()->count() > 0) {
} elseif (($location->children) && ($location->children->count() > 0)) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc')); return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc'));
} elseif ($location->assets()->count() > 0) {
} elseif (($location->assets()) && ($location->assets()->count() > 0)) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets')); return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
} elseif ($location->assignedassets()->count() > 0) {
} elseif (($location->assignedassets()) && ($location->assignedassets()->count() > 0)) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets')); return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
} }
if ($location->image) { if ($location->image) {

View file

@ -162,7 +162,7 @@ class ManufacturersController extends Controller
return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.not_found')); 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')); return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.assoc_users'));
} }
@ -174,7 +174,6 @@ class ManufacturersController extends Controller
} }
} }
// Delete the manufacturer // Delete the manufacturer
$manufacturer->delete(); $manufacturer->delete();
// Redirect to the manufacturers management page // Redirect to the manufacturers management page

View file

@ -6,47 +6,15 @@ use App\Helpers\Helper;
class ModalController extends Controller class ModalController extends Controller
{ {
function location() { function show($type, $itemId = null) {
return view('modals.location'); $view = view("modals.${type}");
}
function model() { if($type == "statuslabel") {
return view('modals.model'); $view->with('statuslabel_types', Helper::statusTypeList());
} }
if(in_array($type, ['kit-model', 'kit-license', 'kit-consumable', 'kit-accessory'])) {
function statuslabel() { $view->with('kitId', $itemId);
return view('modals.statuslabel')->with('statuslabel_types', Helper::statusTypeList()); }
} return $view;
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');
} }
} }

View file

@ -106,7 +106,7 @@ class SuppliersController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update($supplierId = null, ImageUploadRequest $request) public function update($supplierId, ImageUploadRequest $request)
{ {
$this->authorize('update', Supplier::class); $this->authorize('update', Supplier::class);
// Check if the supplier exists // Check if the supplier exists

View file

@ -33,9 +33,6 @@ class BulkUsersController extends Controller
// Make sure there were users selected // Make sure there were users selected
if (($request->filled('ids')) && (count($request->input('ids')) > 0)) { if (($request->filled('ids')) && (count($request->input('ids')) > 0)) {
$statuslabel_list = Helper::statusLabelList();
// Get the list of affected users // Get the list of affected users
$users = User::whereIn('id', array_keys(request('ids'))) $users = User::whereIn('id', array_keys(request('ids')))
->with('groups', 'assets', 'licenses', 'accessories')->get(); ->with('groups', 'assets', 'licenses', 'accessories')->get();
@ -45,17 +42,15 @@ class BulkUsersController extends Controller
->with('groups', Group::pluck('name', 'id')); ->with('groups', Group::pluck('name', 'id'));
} elseif ($request->input('bulk_actions') == 'delete') { } 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') { } elseif ($request->input('bulk_actions') == 'bulkpasswordreset') {
if ($users) { foreach ($users as $user) {
foreach ($users as $user) { if (($user->activated=='1') && ($user->email!='')) {
if (($user->activated=='1') && ($user->email!='')) { $credentials = ['email' => $user->email];
$credentials = ['email' => $user->email]; Password::sendResetLink($credentials, function (Message $message) {
Password::sendResetLink($credentials, function (Message $message) { $message->subject($this->getEmailSubject());
$message->subject($this->getEmailSubject()); });
});
}
} }
} }
return redirect()->back()->with('success', trans('admin/users/message.password_resets_sent')); return redirect()->back()->with('success', trans('admin/users/message.password_resets_sent'));

View file

@ -204,7 +204,7 @@ class UsersController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException * @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 // We need to reverse the UI specific logic for our
// permissions here before we update the user. // permissions here before we update the user.
@ -221,25 +221,20 @@ class UsersController extends Controller
try { try {
$user = User::findOrFail($id); $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) { } catch (ModelNotFoundException $e) {
return redirect()->route('users.index') return redirect()->route('users.index')
->with('error', trans('admin/users/message.user_not_found', compact('id'))); ->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 // Only save groups if the user is a super user
if (Auth::user()->isSuperUser()) { if (Auth::user()->isSuperUser()) {
@ -247,13 +242,11 @@ class UsersController extends Controller
} }
// Update the user
if ($request->filled('username')) { if ($request->filled('username')) {
$user->username = $request->input('username'); $user->username = $request->input('username');
} }
$user->email = $request->input('email'); $user->email = $request->input('email');
// Update the user
$user->first_name = $request->input('first_name'); $user->first_name = $request->input('first_name');
$user->last_name = $request->input('last_name'); $user->last_name = $request->input('last_name');
$user->two_factor_optin = $request->input('two_factor_optin') ?: 0; $user->two_factor_optin = $request->input('two_factor_optin') ?: 0;
@ -382,7 +375,7 @@ class UsersController extends Controller
{ {
$this->authorize('update', User::class); $this->authorize('update', User::class);
// Get user information // 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')); return redirect()->route('users.index')->with('error', trans('admin/users/messages.user_not_found'));
} }

View file

@ -33,7 +33,9 @@ class SaveUserRequest extends FormRequest
public function rules() public function rules()
{ {
$rules = []; $rules = [
'manager_id' => "nullable|exists:users,id|different:users.id"
];
switch($this->method()) switch($this->method())
{ {

View file

@ -45,10 +45,10 @@ class AccessoriesTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'checkout' => Gate::allows('checkout', Accessory::class) ? true : false, 'checkout' => Gate::allows('checkout', Accessory::class),
'checkin' => false, 'checkin' => false,
'update' => Gate::allows('update', Accessory::class) ? true : false, 'update' => Gate::allows('update', Accessory::class) ,
'delete' => Gate::allows('delete', Accessory::class) ? true : false, 'delete' => Gate::allows('delete', Accessory::class),
]; ];
$permissions_array['user_can_checkout'] = false; $permissions_array['user_can_checkout'] = false;

View file

@ -58,8 +58,8 @@ class AssetMaintenancesTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => (bool) Gate::allows('update', Asset::class), 'update' => Gate::allows('update', Asset::class),
'delete' => (bool) Gate::allows('delete', Asset::class), 'delete' => Gate::allows('delete', Asset::class),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -54,10 +54,10 @@ class AssetModelsTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => (Gate::allows('update', 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) && ($assetmodel->deleted_at=='')) ? true : false, 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->assets_count==0)),
'clone' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at=='')) , '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; $array += $permissions_array;

View file

@ -114,20 +114,20 @@ class AssetsTransformer
} }
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'checkout' => (bool) Gate::allows('checkout', Asset::class), 'checkout' => Gate::allows('checkout', Asset::class),
'checkin' => (bool) Gate::allows('checkin', Asset::class), 'checkin' => Gate::allows('checkin', Asset::class),
'clone' => Gate::allows('create', Asset::class) ? true : false, 'clone' => Gate::allows('create', Asset::class),
'restore' => false, 'restore' => false,
'update' => (bool) Gate::allows('update', Asset::class), '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!='') { if ($asset->deleted_at!='') {
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'checkout' => true, 'checkout' => true,
'checkin' => false, 'checkin' => false,
'clone' => Gate::allows('create', Asset::class) ? true : false, 'clone' => Gate::allows('create', Asset::class),
'restore' => Gate::allows('create', Asset::class) ? true : false, 'restore' => Gate::allows('create', Asset::class),
'update' => false, 'update' => false,
'delete' => false, 'delete' => false,
]; ];

View file

@ -27,10 +27,11 @@ class CategoriesTransformer
'id' => (int) $category->id, 'id' => (int) $category->id,
'name' => e($category->name), 'name' => e($category->name),
'image' => ($category->image) ? Storage::disk('public')->url('categories/'.e($category->image)) : null, 'image' => ($category->image) ? Storage::disk('public')->url('categories/'.e($category->image)) : null,
'category_type' => e($category->category_type), 'category_type' => ucwords(e($category->category_type)),
'eula' => ($category->getEula()) ? true : false, 'eula' => ($category->getEula()),
'checkin_email' => ($category->checkin_email =='1') ? true : false, 'checkin_email' => ($category->checkin_email =='1'),
'require_acceptance' => ($category->require_acceptance =='1') ? true : false, 'require_acceptance' => ($category->require_acceptance == '1'),
'item_count' => (int) $category->itemCount(),
'assets_count' => (int) $category->assets_count, 'assets_count' => (int) $category->assets_count,
'accessories_count' => (int) $category->accessories_count, 'accessories_count' => (int) $category->accessories_count,
'consumables_count' => (int) $category->consumables_count, 'consumables_count' => (int) $category->consumables_count,
@ -41,8 +42,8 @@ class CategoriesTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', Category::class) ? true : false, 'update' => Gate::allows('update', Category::class),
'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, 'delete' => $category->isDeletable(),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -38,8 +38,8 @@ class CompaniesTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', Company::class) ? true : false, 'update' => Gate::allows('update', Company::class),
'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, 'delete' => $company->isDeletable()
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -28,10 +28,10 @@ class ComponentsAssetsTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'checkout' => Gate::allows('checkout', Asset::class) ? true : false, 'checkout' => Gate::allows('checkout', Asset::class),
'checkin' => Gate::allows('checkin', Asset::class) ? true : false, 'checkin' => Gate::allows('checkin', Asset::class),
'update' => Gate::allows('update', Asset::class) ? true : false, 'update' => Gate::allows('update', Asset::class),
'delete' => Gate::allows('delete', Asset::class) ? true : false, 'delete' => Gate::allows('delete', Asset::class),
]; ];

View file

@ -49,10 +49,10 @@ class ComponentsTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'checkout' => (bool) Gate::allows('checkout', Component::class), 'checkout' => Gate::allows('checkout', Component::class),
'checkin' => (bool) Gate::allows('checkin', Component::class), 'checkin' => Gate::allows('checkin', Component::class),
'update' => (bool) Gate::allows('update', Component::class), 'update' => Gate::allows('update', Component::class),
'delete' => (bool) Gate::allows('delete', Component::class), 'delete' => Gate::allows('delete', Component::class),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -48,10 +48,10 @@ class ConsumablesTransformer
} }
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'checkout' => Gate::allows('checkout', Consumable::class) ? true : false, 'checkout' => Gate::allows('checkout', Consumable::class),
'checkin' => Gate::allows('checkin', Consumable::class) ? true : false, 'checkin' => Gate::allows('checkin', Consumable::class),
'update' => Gate::allows('update', Consumable::class) ? true : false, 'update' => Gate::allows('update', Consumable::class),
'delete' => Gate::allows('delete', Consumable::class) ? true : false, 'delete' => Gate::allows('delete', Consumable::class),
]; ];
$array += $permissions_array; $array += $permissions_array;
return $array; return $array;

View file

@ -47,8 +47,8 @@ class DepartmentsTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', Department::class) ? true : false, 'update' => Gate::allows('update', Department::class),
'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0) && ($department->deleted_at=='')) ? true : false, 'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -29,8 +29,8 @@ class DepreciationsTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', Depreciation::class) ? true : false, 'update' => Gate::allows('update', Depreciation::class),
'delete' => Gate::allows('delete', Depreciation::class) ? true : false, 'delete' => Gate::allows('delete', Depreciation::class),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -46,15 +46,15 @@ class LicenseSeatsTransformer
'name'=> e($seat->location()->name) 'name'=> e($seat->location()->name)
] : null, ] : null,
'reassignable' => (bool) $seat->license->reassignable, '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'] = [ $permissions_array['available_actions'] = [
'checkout' => Gate::allows('checkout', License::class) ? true : false, 'checkout' => Gate::allows('checkout', License::class),
'checkin' => Gate::allows('checkin', License::class) ? true : false, 'checkin' => Gate::allows('checkin', License::class),
'clone' => Gate::allows('create', License::class) ? true : false, 'clone' => Gate::allows('create', License::class),
'update' => Gate::allows('update', License::class) ? true : false, 'update' => Gate::allows('update', License::class),
'delete' => Gate::allows('delete', License::class) ? true : false, 'delete' => Gate::allows('delete', License::class),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -45,11 +45,11 @@ class LicensesTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'checkout' => Gate::allows('checkout', License::class) ? true : false, 'checkout' => Gate::allows('checkout', License::class),
'checkin' => Gate::allows('checkin', License::class) ? true : false, 'checkin' => Gate::allows('checkin', License::class),
'clone' => Gate::allows('create', License::class) ? true : false, 'clone' => Gate::allows('create', License::class),
'update' => Gate::allows('update', License::class) ? true : false, 'update' => Gate::allows('update', License::class),
'delete' => Gate::allows('delete', License::class) ? true : false, 'delete' => Gate::allows('delete', License::class),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -61,7 +61,7 @@ class LocationsTransformer
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', Location::class) ? true : false, '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; $array += $permissions_array;

View file

@ -41,9 +41,9 @@ class ManufacturersTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => (($manufacturer->deleted_at=='') && (Gate::allows('update', Manufacturer::class))) ? true : false, 'update' => (($manufacturer->deleted_at=='') && (Gate::allows('update', Manufacturer::class))),
'restore' => (($manufacturer->deleted_at!='') && (Gate::allows('create', Manufacturer::class))) ? true : false, 'restore' => (($manufacturer->deleted_at!='') && (Gate::allows('create', Manufacturer::class))),
'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, 'delete' => $manufacturer->isDeletable(),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -34,7 +34,7 @@ class PredefinedKitsTransformer
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', PredefinedKit::class), 'update' => Gate::allows('update', PredefinedKit::class),
'delete' => Gate::allows('delete', 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), // 'clone' => Gate::allows('create', PredefinedKit::class),
// 'restore' => Gate::allows('create', PredefinedKit::class), // 'restore' => Gate::allows('create', PredefinedKit::class),
]; ];

View file

@ -28,16 +28,16 @@ class SuppliersTransformer
'name' => e($supplier->name), 'name' => e($supplier->name),
'image' => ($supplier->image) ? Storage::disk('public')->url('suppliers/'.e($supplier->image)) : null, 'image' => ($supplier->image) ? Storage::disk('public')->url('suppliers/'.e($supplier->image)) : null,
'url' => e($supplier->url), 'url' => e($supplier->url),
'address' => ($supplier->address) ? e($supplier->address) : null, 'address' => e($supplier->address),
'address2' => ($supplier->address2) ? e($supplier->address2) : null, 'address2' => e($supplier->address2),
'city' => ($supplier->city) ? e($supplier->city) : null, 'city' => e($supplier->city),
'state' => ($supplier->state) ? e($supplier->state) : null, 'state' => e($supplier->state),
'country' => ($supplier->country) ? e($supplier->country) : null, 'country' => e($supplier->country),
'zip' => ($supplier->zip) ? e($supplier->zip) : null, 'zip' => e($supplier->zip),
'fax' => ($supplier->fax) ? e($supplier->fax) : null, 'fax' => e($supplier->fax),
'phone' => ($supplier->phone) ? e($supplier->phone) : null, 'phone' => e($supplier->phone),
'email' => ($supplier->email) ? e($supplier->email) : null, 'email' => e($supplier->email),
'contact' => ($supplier->contact) ? e($supplier->contact) : null, 'contact' => e($supplier->contact),
'assets_count' => (int) $supplier->assets_count, 'assets_count' => (int) $supplier->assets_count,
'accessories_count' => (int) $supplier->accessories_count, 'accessories_count' => (int) $supplier->accessories_count,
'licenses_count' => (int) $supplier->licenses_count, 'licenses_count' => (int) $supplier->licenses_count,
@ -48,8 +48,8 @@ class SuppliersTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => Gate::allows('update', Supplier::class) ? 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)) ? true : false, 'delete' => (Gate::allows('delete', Supplier::class) && ($supplier->assets_count == 0) && ($supplier->licenses_count == 0) && ($supplier->accessories_count == 0)),
]; ];
$array += $permissions_array; $array += $permissions_array;

View file

@ -66,10 +66,10 @@ class UsersTransformer
]; ];
$permissions_array['available_actions'] = [ $permissions_array['available_actions'] = [
'update' => (Gate::allows('update', User::class) && ($user->deleted_at=='')) ? true : false, 'update' => (Gate::allows('update', User::class) && ($user->deleted_at=='')),
'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, '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=='')) , '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; $array += $permissions_array;

View file

@ -5,6 +5,7 @@ use App\Http\Traits\UniqueUndeletedTrait;
use App\Models\Traits\Searchable; use App\Models\Traits\Searchable;
use App\Presenters\Presentable; use App\Presenters\Presentable;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Gate;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
/** /**
@ -69,22 +70,35 @@ class Category extends SnipeModel
]; ];
use Searchable; use Searchable;
/** /**
* The attributes that should be included when searching the model. * The attributes that should be included when searching the model.
* *
* @var array * @var array
*/ */
protected $searchableAttributes = ['name', 'category_type']; protected $searchableAttributes = ['name', 'category_type'];
/** /**
* The relations and their attributes that should be included when searching the model. * The relations and their attributes that should be included when searching the model.
* *
* @var array * @var array
*/ */
protected $searchableRelations = []; 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 * Establishes the category -> accessories relationship
* *

View file

@ -5,6 +5,7 @@ use App\Models\Traits\Searchable;
use App\Presenters\Presentable; use App\Presenters\Presentable;
use Auth; use Auth;
use DB; use DB;
use Illuminate\Support\Facades\Gate;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
/** /**
@ -84,7 +85,6 @@ final class Company extends SnipeModel
} else { } else {
return $query->join('users as users_comp', 'users_comp.id', 'user_id')->where('users_comp.company_id', '=', $company_id); 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) public static function getIdFromInput($unescaped_input)
@ -143,6 +143,22 @@ final class Company extends SnipeModel
Auth::user()->company_id == null); 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) public static function getIdForUser($unescaped_input)
{ {
if (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->isSuperUser()) { if (!static::isFullMultipleCompanySupportEnabled() || Auth::user()->isSuperUser()) {

View file

@ -7,10 +7,11 @@ use App\Models\SnipeModel;
use App\Models\Traits\Searchable; use App\Models\Traits\Searchable;
use App\Models\User; use App\Models\User;
use App\Presenters\Presentable; use App\Presenters\Presentable;
use DB;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Gate;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
use DB;
class Location extends SnipeModel class Location extends SnipeModel
{ {
@ -86,6 +87,14 @@ class Location extends SnipeModel
'parent' => ['name'] '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() public function users()
{ {
return $this->hasMany('\App\Models\User', 'location_id'); return $this->hasMany('\App\Models\User', 'location_id');

View file

@ -4,6 +4,7 @@ namespace App\Models;
use App\Models\Traits\Searchable; use App\Models\Traits\Searchable;
use App\Presenters\Presentable; use App\Presenters\Presentable;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Gate;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
class Manufacturer extends SnipeModel class Manufacturer extends SnipeModel
@ -49,22 +50,30 @@ class Manufacturer extends SnipeModel
]; ];
use Searchable; use Searchable;
/** /**
* The attributes that should be included when searching the model. * The attributes that should be included when searching the model.
* *
* @var array * @var array
*/ */
protected $searchableAttributes = ['name', 'created_at']; protected $searchableAttributes = ['name', 'created_at'];
/** /**
* The relations and their attributes that should be included when searching the model. * The relations and their attributes that should be included when searching the model.
* *
* @var array * @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() public function assets()
{ {

View file

@ -29,10 +29,9 @@ class AuditNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint) { if (Setting::getSettings()->slack_endpoint) {
@ -42,13 +41,13 @@ class AuditNotification extends Notification
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable) public function toSlack()
{ {
return (new SlackMessage) return (new SlackMessage)
->success() ->success()
->content(class_basename(get_class($this->params['item'])) . " Audited") ->content(class_basename(get_class($this->params['item'])) . " Audited")
->attachment(function ($attachment) use ($notifiable) { ->attachment(function ($attachment) {
$item = $this->params['item']; $item = $this->params['item'];
$admin_user = $this->params['admin']; $admin_user = $this->params['admin'];
$fields = [ $fields = [
@ -61,27 +60,4 @@ class AuditNotification extends Notification
->fields($fields); ->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 [
//
];
}
} }

View file

@ -31,7 +31,6 @@ class CheckinAccessoryNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via() public function via()
@ -65,14 +64,11 @@ class CheckinAccessoryNotification extends Notification
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot' ; $botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot' ;
$fields = [ $fields = [
'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>', 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>',
'By' => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', 'By' => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>',
]; ];
return (new SlackMessage) return (new SlackMessage)
->content(':arrow_down: :keyboard: Accessory Checked In') ->content(':arrow_down: :keyboard: Accessory Checked In')
->from($botname) ->from($botname)
@ -88,10 +84,8 @@ class CheckinAccessoryNotification extends Notification
* @param mixed $notifiable * @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
return (new MailMessage)->markdown('notifications.markdown.checkin-accessory', return (new MailMessage)->markdown('notifications.markdown.checkin-accessory',
[ [
'item' => $this->item, 'item' => $this->item,
@ -102,17 +96,4 @@ class CheckinAccessoryNotification extends Notification
->subject('Accessory checked in'); ->subject('Accessory checked in');
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -39,7 +39,6 @@ class CheckinAssetNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via() 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. * has the corresponding checkbox checked.
*/ */
if ($this->item->checkin_email() && $this->target instanceof User && $this->target->email != '') 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.status') => $item->assetstatus->name,
trans('general.location') => ($item->location) ? $item->location->name : '', trans('general.location') => ($item->location) ? $item->location->name : '',
]; ];
return (new SlackMessage) return (new SlackMessage)
->content(':arrow_down: :computer: Asset Checked In') ->content(':arrow_down: :computer: Asset Checked In')
->from($botname) ->from($botname)
@ -94,13 +93,10 @@ class CheckinAssetNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail() public function toMail()
{ {
$fields = []; $fields = [];
// Check if the item has custom fields associated with it // Check if the item has custom fields associated with it

View file

@ -35,10 +35,9 @@ class CheckinLicenseSeatNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $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. * has the corresponding checkbox checked.
*/ */
if ($this->item->checkin_email() && $this->target instanceof User && $this->target->email != '') if ($this->item->checkin_email() && $this->target instanceof User && $this->target->email != '')
@ -58,7 +57,7 @@ class CheckinLicenseSeatNotification extends Notification
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable) public function toSlack()
{ {
$target = $this->target; $target = $this->target;
@ -90,7 +89,7 @@ class CheckinLicenseSeatNotification extends Notification
* @param mixed $notifiable * @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
return (new MailMessage)->markdown('notifications.markdown.checkin-license', 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 [
//
];
}
} }

View file

@ -25,7 +25,7 @@ class CheckoutAccessoryNotification extends Notification
$this->note = $note; $this->note = $note;
$this->target = $checkedOutTo; $this->target = $checkedOutTo;
$this->acceptance = $acceptance; $this->acceptance = $acceptance;
$this->settings = Setting::getSettings(); $this->settings = Setting::getSettings();
} }
@ -33,10 +33,9 @@ class CheckoutAccessoryNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $notifyBy = [];
@ -52,7 +51,7 @@ class CheckoutAccessoryNotification extends Notification
if ($this->target instanceof User && $this->target->email != '') { 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 * so the user can accept or decline the asset
*/ */
if ($this->item->requireAcceptance()) { if ($this->item->requireAcceptance()) {
@ -71,17 +70,15 @@ class CheckoutAccessoryNotification extends Notification
*/ */
if ($this->item->checkin_email()) { if ($this->item->checkin_email()) {
$notifyBy[1] = 'mail'; $notifyBy[1] = 'mail';
} }
} }
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable) public function toSlack()
{ {
$target = $this->target; $target = $this->target;
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
@ -93,8 +90,6 @@ class CheckoutAccessoryNotification extends Notification
'By' => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', 'By' => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>',
]; ];
return (new SlackMessage) return (new SlackMessage)
->content(':arrow_up: :keyboard: Accessory Checked Out') ->content(':arrow_up: :keyboard: Accessory Checked Out')
->from($botname) ->from($botname)
@ -107,12 +102,10 @@ class CheckoutAccessoryNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
\Log::debug($this->item->getImageUrl()); \Log::debug($this->item->getImageUrl());
$eula = $this->item->getEula(); $eula = $this->item->getEula();
$req_accept = $this->item->requireAcceptance(); $req_accept = $this->item->requireAcceptance();
@ -132,17 +125,4 @@ class CheckoutAccessoryNotification extends Notification
->subject(trans('mail.Confirm_accessory_delivery')); ->subject(trans('mail.Confirm_accessory_delivery'));
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -49,7 +49,6 @@ class CheckoutAssetNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via() public function via()
@ -68,7 +67,7 @@ class CheckoutAssetNotification extends Notification
if ($this->target instanceof User && $this->target->email != '') { 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 * so the user can accept or decline the asset
*/ */
if ($this->item->requireAcceptance()) { if ($this->item->requireAcceptance()) {
@ -80,14 +79,14 @@ class CheckoutAssetNotification extends Notification
*/ */
if ($this->item->getEula()) { if ($this->item->getEula()) {
$notifyBy[1] = 'mail'; $notifyBy[1] = 'mail';
} }
/** /**
* Send an email if an email should be sent at checkin/checkout * Send an email if an email should be sent at checkin/checkout
*/ */
if ($this->item->checkin_email()) { if ($this->item->checkin_email()) {
$notifyBy[1] = 'mail'; $notifyBy[1] = 'mail';
} }
} }
@ -160,7 +159,6 @@ class CheckoutAssetNotification extends Notification
return $message; return $message;
} }
} }

View file

@ -39,10 +39,9 @@ class CheckoutConsumableNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $notifyBy = [];
@ -56,7 +55,7 @@ class CheckoutConsumableNotification extends Notification
if ($this->target instanceof User && $this->target->email != '') { 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 * so the user can accept or decline the asset
*/ */
if ($this->item->requireAcceptance()) { if ($this->item->requireAcceptance()) {
@ -68,7 +67,7 @@ class CheckoutConsumableNotification extends Notification
*/ */
if ($this->item->getEula()) { if ($this->item->getEula()) {
$notifyBy[1] = 'mail'; $notifyBy[1] = 'mail';
} }
/** /**
* Send an email if an email should be sent at checkin/checkout * 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())) { if ((method_exists($this->item, 'checkin_email')) && ($this->item->checkin_email())) {
$notifyBy[1] = 'mail'; $notifyBy[1] = 'mail';
} }
} }
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable) public function toSlack()
{ {
$target = $this->target; $target = $this->target;
$admin = $this->admin; $admin = $this->admin;
@ -109,10 +108,9 @@ class CheckoutConsumableNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
\Log::debug($this->item->getImageUrl()); \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 [
//
];
}
} }

View file

@ -37,7 +37,6 @@ class CheckoutLicenseSeatNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via() public function via()
@ -54,7 +53,7 @@ class CheckoutLicenseSeatNotification extends Notification
if ($this->target instanceof User && $this->target->email != '') { 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 * so the user can accept or decline the asset
*/ */
if ($this->item->requireAcceptance()) { if ($this->item->requireAcceptance()) {
@ -66,23 +65,22 @@ class CheckoutLicenseSeatNotification extends Notification
*/ */
if ($this->item->getEula()) { if ($this->item->getEula()) {
$notifyBy[1] = 'mail'; $notifyBy[1] = 'mail';
} }
/** /**
* Send an email if an email should be sent at checkin/checkout * Send an email if an email should be sent at checkin/checkout
*/ */
if ($this->item->checkin_email()) { if ($this->item->checkin_email()) {
$notifyBy[1] = 'mail'; $notifyBy[1] = 'mail';
} }
} }
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable) public function toSlack()
{ {
$target = $this->target; $target = $this->target;
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
@ -106,10 +104,9 @@ class CheckoutLicenseSeatNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
$eula = method_exists($this->item, 'getEula') ? $this->item->getEula() : ''; $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 [
//
];
}
} }

View file

@ -26,7 +26,7 @@ class CurrentInventory extends Notification
* @param mixed $notifiable * @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
return ['mail']; return ['mail'];
} }
@ -34,10 +34,9 @@ class CurrentInventory extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
$message = (new MailMessage)->markdown('notifications.markdown.user-inventory', $message = (new MailMessage)->markdown('notifications.markdown.user-inventory',
[ [
@ -49,17 +48,4 @@ class CurrentInventory extends Notification
return $message; return $message;
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -27,28 +27,21 @@ class ExpectedCheckinAdminNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $notifyBy = [];
$notifyBy[]='mail'; $notifyBy[]='mail';
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable)
{
}
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $asset
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($params) public function toMail()
{ {
$message = (new MailMessage)->markdown('notifications.markdown.report-expected-checkins', $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 [
//
];
}
} }

View file

@ -28,10 +28,9 @@ class ExpectedCheckinNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $notifyBy = [];
$item = $this->params['item']; $item = $this->params['item'];
@ -40,18 +39,12 @@ class ExpectedCheckinNotification extends Notification
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable)
{
}
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $asset
* @return \Illuminate\Notifications\Messages\MailMessage * @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'); $formatted_due = Carbon::parse($this->params->expected_checkin)->format('D, M j, Y');
return (new MailMessage) return (new MailMessage)
@ -63,20 +56,6 @@ class ExpectedCheckinNotification extends Notification
->line('Serial: '.$this->params->serial) ->line('Serial: '.$this->params->serial)
->line('Asset Tag: '.$this->params->asset_tag) ->line('Asset Tag: '.$this->params->asset_tag)
->action('View Your Assets', route('view-assets')); ->action('View Your Assets', route('view-assets'));
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -28,28 +28,22 @@ class ExpiringAssetsNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $notifyBy = [];
$notifyBy[]='mail'; $notifyBy[]='mail';
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable)
{
}
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $asset * @param mixed $asset
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($params) public function toMail()
{ {
$message = (new MailMessage)->markdown('notifications.markdown.report-expiring-assets', $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 [
//
];
}
} }

View file

@ -31,25 +31,20 @@ class ExpiringLicenseNotification extends Notification
* @param mixed $notifiable * @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy = []; $notifyBy = [];
$notifyBy[]='mail'; $notifyBy[]='mail';
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable)
{
}
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $asset * @param mixed $asset
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($params) public function toMail()
{ {
$message = (new MailMessage)->markdown('notifications.markdown.report-expiring-licenses', $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 [
//
];
}
} }

View file

@ -30,10 +30,9 @@ class FirstAdminNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
return ['mail']; return ['mail'];
} }
@ -41,26 +40,13 @@ class FirstAdminNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
return (new MailMessage) return (new MailMessage)
->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ])) ->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ]))
->markdown('notifications.FirstAdmin', $this->_data); ->markdown('notifications.FirstAdmin', $this->_data);
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -28,27 +28,21 @@ class InventoryAlert extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
$notifyBy[] = 'mail'; $notifyBy[] = 'mail';
return $notifyBy; return $notifyBy;
} }
public function toSlack($notifiable)
{
}
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $asset
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($params) public function toMail()
{ {
$message = (new MailMessage)->markdown( $message = (new MailMessage)->markdown(
'notifications.markdown.report-low-inventory', 'notifications.markdown.report-low-inventory',
@ -61,17 +55,4 @@ class InventoryAlert extends Notification
return $message; return $message;
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -24,10 +24,9 @@ class MailTest extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
return ['mail']; return ['mail'];
} }
@ -35,26 +34,12 @@ class MailTest extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
return (new MailMessage) return (new MailMessage)
->subject(trans('mail.test_email')) ->subject(trans('mail.test_email'))
->markdown('notifications.Test'); ->markdown('notifications.Test');
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -2,6 +2,7 @@
namespace App\Notifications; namespace App\Notifications;
use App\Helpers\Helper;
use App\Models\Setting; use App\Models\Setting;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;
@ -27,7 +28,7 @@ class RequestAssetCancelation extends Notification
$this->last_checkout = ''; $this->last_checkout = '';
$this->item_quantity = $params['item_quantity']; $this->item_quantity = $params['item_quantity'];
$this->expected_checkin = ''; $this->expected_checkin = '';
$this->requested_date = \App\Helpers\Helper::getFormattedDateObject($params['requested_date'], 'datetime', $this->requested_date = Helper::getFormattedDateObject($params['requested_date'], 'datetime',
false); false);
$this->settings = Setting::getSettings(); $this->settings = Setting::getSettings();
@ -36,16 +37,14 @@ class RequestAssetCancelation extends Notification
} }
if ($this->item->last_checkout) { 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); false);
} }
if ($this->item->expected_checkin) { 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); false);
} }
} }
/** /**
@ -72,8 +71,6 @@ class RequestAssetCancelation extends Notification
public function toSlack() public function toSlack()
{ {
$target = $this->target; $target = $this->target;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
@ -130,8 +127,6 @@ class RequestAssetCancelation extends Notification
return $message; return $message;
} }
} }

View file

@ -2,6 +2,7 @@
namespace App\Notifications; namespace App\Notifications;
use App\Helpers\Helper;
use App\Models\Setting; use App\Models\Setting;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;
@ -28,7 +29,7 @@ class RequestAssetNotification extends Notification
$this->note = ''; $this->note = '';
$this->last_checkout = ''; $this->last_checkout = '';
$this->expected_checkin = ''; $this->expected_checkin = '';
$this->requested_date = \App\Helpers\Helper::getFormattedDateObject($params['requested_date'], 'datetime', $this->requested_date = Helper::getFormattedDateObject($params['requested_date'], 'datetime',
false); false);
$this->settings = Setting::getSettings(); $this->settings = Setting::getSettings();
@ -37,12 +38,12 @@ class RequestAssetNotification extends Notification
} }
if ($this->item->last_checkout) { 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); false);
} }
if ($this->item->expected_checkin) { 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); false);
} }
@ -73,8 +74,6 @@ class RequestAssetNotification extends Notification
public function toSlack() public function toSlack()
{ {
$target = $this->target; $target = $this->target;
$qty = $this->item_quantity; $qty = $this->item_quantity;
$item = $this->item; $item = $this->item;
@ -98,7 +97,6 @@ class RequestAssetNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail() public function toMail()
@ -127,8 +125,6 @@ class RequestAssetNotification extends Notification
return $message; return $message;
} }
} }

View file

@ -26,10 +26,9 @@ class SendUpcomingAuditNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
return $notifyBy = ['mail']; return $notifyBy = ['mail'];
} }
@ -37,10 +36,9 @@ class SendUpcomingAuditNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
$message = (new MailMessage)->markdown('notifications.markdown.upcoming-audits', $message = (new MailMessage)->markdown('notifications.markdown.upcoming-audits',
[ [
@ -51,17 +49,4 @@ class SendUpcomingAuditNotification extends Notification
return $message; return $message;
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -32,26 +32,13 @@ class SlackTest extends Notification
return ['slack']; 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. * Get the Slack representation of the notification.
* *
* @param mixed $notifiable * @param mixed $notifiable
* @return SlackMessage * @return SlackMessage
*/ */
public function toSlack($notifiable) public function toSlack()
{ {
$settings = Setting::getSettings(); $settings = Setting::getSettings();
return (new SlackMessage) return (new SlackMessage)
@ -61,17 +48,4 @@ class SlackTest extends Notification
->content('Oh hai! Looks like your Slack integration with Snipe-IT is working!'); ->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 [
//
];
}
} }

View file

@ -30,10 +30,9 @@ class WelcomeNotification extends Notification
/** /**
* Get the notification's delivery channels. * Get the notification's delivery channels.
* *
* @param mixed $notifiable
* @return array * @return array
*/ */
public function via($notifiable) public function via()
{ {
return ['mail']; return ['mail'];
} }
@ -41,26 +40,12 @@ class WelcomeNotification extends Notification
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail()
{ {
return (new MailMessage) return (new MailMessage)
->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ])) ->subject(trans('mail.welcome', ['name' => $this->_data['first_name'] . ' ' . $this->_data['last_name'] ]))
->markdown('notifications.Welcome', $this->_data); ->markdown('notifications.Welcome', $this->_data);
} }
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
} }

View file

@ -91,7 +91,11 @@ abstract class SnipePermissionsPolicy
*/ */
public function delete(User $user, $item = null) 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');
} }
/** /**

View file

@ -43,52 +43,27 @@ class CategoryPresenter extends Presenter
"sortable" => true, "sortable" => true,
"title" => trans('general.type'), "title" => trans('general.type'),
"visible" => true "visible" => true
], [ ],[
"field" => "assets_count", "field" => "item_count",
"searchable" => false, "searchable" => false,
"sortable" => true, "sortable" => true,
"title" => trans('general.assets'), "title" => trans('general.qty'),
"visible" => true "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", "field" => "eula",
"searchable" => false, "searchable" => false,
"sortable" => false, "sortable" => false,
"title" => trans('admin/categories/table.eula_text'), "title" => trans('admin/categories/table.eula_text'),
"visible" => false, "visible" => false,
"formatter" => 'trueFalseFormatter', "formatter" => 'trueFalseFormatter',
], [ ],[
"field" => "require_acceptance", "field" => "require_acceptance",
"searchable" => false, "searchable" => false,
"sortable" => true, "sortable" => true,
"title" => trans('admin/categories/table.require_acceptance'), "title" => trans('admin/categories/table.require_acceptance'),
"visible" => true, "visible" => true,
"formatter" => 'trueFalseFormatter', "formatter" => 'trueFalseFormatter',
], ],[
[
"field" => "actions", "field" => "actions",
"searchable" => false, "searchable" => false,
"sortable" => false, "sortable" => false,

View file

@ -11,7 +11,7 @@
Create a Button looking like this: 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' If you don't have access to Blade commands (like {{ and }}, etc), you can hard-code a URL as the 'href'

View file

@ -211,7 +211,7 @@
'unknown_admin' => 'Unknown Admin', 'unknown_admin' => 'Unknown Admin',
'username_format' => 'Username Format', 'username_format' => 'Username Format',
'update' => 'Update', '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', 'uploaded' => 'Uploaded',
'user' => 'User', 'user' => 'User',
'accepted' => 'accepted', 'accepted' => 'accepted',

View file

@ -39,7 +39,7 @@
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'> }'>
</table> </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>
</div> <!--.box-body--> </div> <!--.box-body-->
</div> <!-- /.box.box-default--> </div> <!-- /.box.box-default-->
@ -73,7 +73,7 @@
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'> }'>
</table> </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>
</div> <!--.box-body--> </div> <!--.box-body-->
</div> <!-- /.box.box-default--> </div> <!-- /.box.box-default-->
@ -107,7 +107,7 @@
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'> }'>
</table> </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>
</div> <!--.box-body--> </div> <!--.box-body-->
</div> <!-- /.box.box-default--> </div> <!-- /.box.box-default-->
@ -141,7 +141,7 @@
"ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"]
}'> }'>
</table> </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>
</div> <!--.box-body--> </div> <!--.box-body-->
</div> <!-- /.box.box-default--> </div> <!-- /.box.box-default-->

View file

@ -7,11 +7,11 @@
<h4 class="modal-title">Append accessory{{-- TODO: trans --}}</h4> <h4 class="modal-title">Append accessory{{-- TODO: trans --}}</h4>
</div> </div>
<div class="modal-body"> <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() }} {{ csrf_field() }}
<div class="alert alert-danger" id="modal_error_msg" style="display:none"> <div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div> </div>
<div class="dynamic-form-row"> <div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-accessory_id">{{ trans('general.accessory') }}: <div class="col-md-4 col-xs-12"><label for="modal-accessory_id">{{ trans('general.accessory') }}:
</label></div> </label></div>

View file

@ -7,11 +7,11 @@
<h4 class="modal-title">Append consumable{{-- TODO: trans --}}</h4> <h4 class="modal-title">Append consumable{{-- TODO: trans --}}</h4>
</div> </div>
<div class="modal-body"> <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() }} {{ csrf_field() }}
<div class="alert alert-danger" id="modal_error_msg" style="display:none"> <div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div> </div>
<div class="dynamic-form-row"> <div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-consumable_id">{{ trans('general.consumable') }}: <div class="col-md-4 col-xs-12"><label for="modal-consumable_id">{{ trans('general.consumable') }}:
</label></div> </label></div>

View file

@ -7,11 +7,11 @@
<h4 class="modal-title">Append license{{-- TODO: trans --}}</h4> <h4 class="modal-title">Append license{{-- TODO: trans --}}</h4>
</div> </div>
<div class="modal-body"> <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() }} {{ csrf_field() }}
<div class="alert alert-danger" id="modal_error_msg" style="display:none"> <div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div> </div>
<div class="dynamic-form-row"> <div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-license_id">{{ trans('general.license') }}: <div class="col-md-4 col-xs-12"><label for="modal-license_id">{{ trans('general.license') }}:
</label></div> </label></div>

View file

@ -7,7 +7,7 @@
<h4 class="modal-title">Append model{{-- TODO: trans --}}</h4> <h4 class="modal-title">Append model{{-- TODO: trans --}}</h4>
</div> </div>
<div class="modal-body"> <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() }} {{ csrf_field() }}
<div class="alert alert-danger" id="modal_error_msg" style="display:none"> <div class="alert alert-danger" id="modal_error_msg" style="display:none">
</div> </div>

View file

@ -19,7 +19,7 @@
<label class="btn btn-default"> <label class="btn btn-default">
{{ trans('button.select_file') }} {{ 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> </label>
</div> </div>

View file

@ -18,7 +18,7 @@
<div class="col-md-1 col-sm-1 text-left"> <div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\Category::class) @can('create', \App\Models\Category::class)
@if ((!isset($hide_new)) || ($hide_new!='true')) @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 @endif
@endcan @endcan
</div> </div>

View file

@ -17,7 +17,7 @@
<div class="col-md-1 col-sm-1 text-left"> <div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\PredefinedKit::class) @can('create', \App\Models\PredefinedKit::class)
@if ((!isset($hide_new)) || ($hide_new!='true')) @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 @endif
@endcan @endcan
</div> </div>

View file

@ -17,7 +17,7 @@
<div class="col-md-1 col-sm-1 text-left"> <div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\Location::class) @can('create', \App\Models\Location::class)
@if ((!isset($hide_new)) || ($hide_new!='true')) @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 @endif
@endcan @endcan
</div> </div>

View file

@ -19,7 +19,7 @@
<div class="col-md-1 col-sm-1 text-left"> <div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\Manufacturer::class) @can('create', \App\Models\Manufacturer::class)
@if ((!isset($hide_new)) || ($hide_new!='true')) @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 @endif
@endcan @endcan
</div> </div>

View file

@ -18,7 +18,7 @@
<div class="col-md-1 col-sm-1 text-left"> <div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\AssetModel::class) @can('create', \App\Models\AssetModel::class)
@if ((!isset($hide_new)) || ($hide_new!='true')) @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;"> <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> <i class="fa fa-spinner fa-spin" aria-hidden="true"></i>
</span> </span>

View file

@ -8,7 +8,7 @@
<div class="col-md-2 col-sm-2 text-left"> <div class="col-md-2 col-sm-2 text-left">
@can('create', \App\Models\Statuslabel::class) @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 @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> <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>

View file

@ -17,7 +17,7 @@
<div class="col-md-1 col-sm-1 text-left"> <div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\Supplier::class) @can('create', \App\Models\Supplier::class)
@if ((!isset($hide_new)) || ($hide_new!='true')) @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 @endif
@endcan @endcan
</div> </div>

View file

@ -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>') !!} {!! $errors->first('supplier_id', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
</div> </div>
<div class="col-md-1 col-sm-1 text-left"> <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>
</div> </div>

View file

@ -17,7 +17,7 @@
<div class="col-md-1 col-sm-1 text-left"> <div class="col-md-1 col-sm-1 text-left">
@can('create', \App\Models\User::class) @can('create', \App\Models\User::class)
@if ((!isset($hide_new)) || ($hide_new!='true')) @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 @endif
@endcan @endcan
</div> </div>

View file

@ -80,17 +80,7 @@ Route::group(['middleware' => 'auth'], function () {
*/ */
Route::group(['middleware' => 'auth','prefix' => 'modals'], function () { Route::group(['middleware' => 'auth','prefix' => 'modals'], function () {
Route::get('location',['as' => 'modal.location','uses' => 'ModalController@location']); Route::get('{type}/{itemId?}',['as' => 'modal.show', 'uses' => 'ModalController@show']);
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']);
}); });
/* /*