2017-11-06 21:17:17 -08:00
|
|
|
<?php
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2017-11-06 21:17:17 -08:00
|
|
|
namespace App\Providers;
|
|
|
|
|
2020-02-10 12:36:40 -08:00
|
|
|
use App\Models\Setting;
|
2021-06-10 13:15:52 -07:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2017-11-06 21:17:17 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This service provider handles sharing the snipeSettings variable, and sets
|
|
|
|
* some common upload path and image urls.
|
|
|
|
*
|
|
|
|
* PHP version 5.5.9
|
|
|
|
* @version v3.0
|
|
|
|
*/
|
|
|
|
class SettingsServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Custom email array validation
|
|
|
|
*
|
|
|
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
|
|
|
* @since [v3.0]
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
|
|
|
|
// Share common setting variables with all views.
|
|
|
|
view()->composer('*', function ($view) {
|
2020-02-10 12:36:40 -08:00
|
|
|
$view->with('snipeSettings', Setting::getSettings());
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2023-04-16 08:46:39 -07:00
|
|
|
|
|
|
|
// Make sure the limit is actually set, is an integer and does not exceed system limits
|
|
|
|
\App::singleton('api_limit_value', function () {
|
|
|
|
$limit = config('app.max_results');
|
2023-10-07 03:34:37 -07:00
|
|
|
$int_limit = intval(request('limit'));
|
2023-04-16 08:46:39 -07:00
|
|
|
|
2023-10-07 03:34:37 -07:00
|
|
|
if ((abs($int_limit) > 0) && ($int_limit <= config('app.max_results'))) {
|
|
|
|
$limit = abs($int_limit);
|
2023-04-16 08:46:39 -07:00
|
|
|
}
|
2023-10-14 12:39:52 -07:00
|
|
|
|
2023-04-16 08:46:39 -07:00
|
|
|
return $limit;
|
|
|
|
});
|
|
|
|
|
2023-10-14 12:39:52 -07:00
|
|
|
// Make sure the offset is actually set and is an integer
|
|
|
|
\App::singleton('api_offset_value', function () {
|
|
|
|
$offset = intval(request('offset'));
|
|
|
|
return $offset;
|
|
|
|
});
|
|
|
|
|
2023-04-16 08:46:39 -07:00
|
|
|
|
2017-11-06 21:17:17 -08:00
|
|
|
/**
|
|
|
|
* Set some common variables so that they're globally available.
|
|
|
|
* The paths should always be public (versus private uploads)
|
|
|
|
*/
|
2018-09-29 21:33:52 -07:00
|
|
|
|
2017-11-06 21:17:17 -08:00
|
|
|
// Model paths and URLs
|
2018-09-29 21:33:52 -07:00
|
|
|
|
2022-05-17 07:01:12 -07:00
|
|
|
|
|
|
|
\App::singleton('eula_pdf_path', function () {
|
|
|
|
return 'eula_pdf_path/';
|
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('assets_upload_path', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'assets/';
|
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('accessories_upload_path', function () {
|
2020-06-16 16:06:25 -07:00
|
|
|
return 'public/uploads/accessories/';
|
2019-02-08 15:43:11 -08:00
|
|
|
});
|
2018-09-29 21:33:52 -07:00
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('models_upload_path', function () {
|
2019-12-04 15:23:49 -08:00
|
|
|
return 'models/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('models_upload_url', function () {
|
2019-12-04 15:23:49 -08:00
|
|
|
return 'models/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Categories
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('categories_upload_path', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'categories/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('categories_upload_url', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'categories/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Locations
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('locations_upload_path', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'locations/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('locations_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'locations/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Users
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('users_upload_path', function () {
|
2020-03-05 18:00:24 -08:00
|
|
|
return 'avatars/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('users_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'users/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Manufacturers
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('manufacturers_upload_path', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'manufacturers/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('manufacturers_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'manufacturers/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Suppliers
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('suppliers_upload_path', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'suppliers/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('suppliers_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'suppliers/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Departments
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('departments_upload_path', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'departments/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('departments_upload_url', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'departments/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2017-11-07 11:28:13 -08:00
|
|
|
// Company paths and URLs
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('companies_upload_path', function () {
|
2018-09-29 21:33:52 -07:00
|
|
|
return 'companies/';
|
2017-11-07 11:28:13 -08:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('companies_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'companies/';
|
2017-11-07 11:28:13 -08:00
|
|
|
});
|
|
|
|
|
2019-05-24 18:22:57 -07:00
|
|
|
// Accessories paths and URLs
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('accessories_upload_path', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'accessories/';
|
2019-05-24 18:22:57 -07:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('accessories_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'accessories/';
|
2019-05-24 18:22:57 -07:00
|
|
|
});
|
|
|
|
|
2019-05-24 19:11:08 -07:00
|
|
|
// Consumables paths and URLs
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('consumables_upload_path', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'consumables/';
|
2019-05-24 19:11:08 -07:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('consumables_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'consumables/';
|
2019-05-24 19:11:08 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
// Components paths and URLs
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('components_upload_path', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'components/';
|
2019-05-24 19:11:08 -07:00
|
|
|
});
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
\App::singleton('components_upload_url', function () {
|
2020-08-03 11:17:56 -07:00
|
|
|
return 'components/';
|
2019-05-24 19:11:08 -07:00
|
|
|
});
|
|
|
|
|
2017-11-06 21:17:17 -08:00
|
|
|
// Set the monetary locale to the configured locale to make helper::parseFloat work.
|
|
|
|
setlocale(LC_MONETARY, config('app.locale'));
|
|
|
|
setlocale(LC_NUMERIC, config('app.locale'));
|
2023-03-21 21:00:43 -07:00
|
|
|
|
2017-11-06 21:17:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|