snipe-it/app/Providers/SettingsServiceProvider.php
snipe 5290c47e2a Merge branch 'develop' into v5-master-develop-integration
# Conflicts:
#	.env.example
#	.travis.yml
#	Dockerfile
#	README.md
#	app/Console/Commands/LdapSync.php
#	app/Console/Kernel.php
#	app/Http/Controllers/AccessoriesController.php
#	app/Http/Controllers/Api/AccessoriesController.php
#	app/Http/Controllers/Api/AssetsController.php
#	app/Http/Controllers/Api/LocationsController.php
#	app/Http/Controllers/Api/SettingsController.php
#	app/Http/Controllers/Api/UsersController.php
#	app/Http/Controllers/AssetModelsController.php
#	app/Http/Controllers/Assets/AssetFilesController.php
#	app/Http/Controllers/Assets/AssetsController.php
#	app/Http/Controllers/CategoriesController.php
#	app/Http/Controllers/CompaniesController.php
#	app/Http/Controllers/ComponentsController.php
#	app/Http/Controllers/ConsumablesController.php
#	app/Http/Controllers/DepartmentsController.php
#	app/Http/Controllers/LicensesController.php
#	app/Http/Controllers/LocationsController.php
#	app/Http/Controllers/ManufacturersController.php
#	app/Http/Controllers/ReportsController.php
#	app/Http/Controllers/SettingsController.php
#	app/Http/Controllers/SuppliersController.php
#	app/Http/Controllers/UsersController.php
#	app/Http/Middleware/EncryptCookies.php
#	app/Http/Requests/AssetRequest.php
#	app/Http/Transformers/AssetMaintenancesTransformer.php
#	app/Importer/AssetImporter.php
#	app/Models/AssetMaintenance.php
#	app/Models/Location.php
#	app/Models/User.php
#	composer.json
#	composer.lock
#	config/backup.php
#	config/database.php
#	config/version.php
#	public/mix-manifest.json
#	resources/lang/en-ID/general.php
#	resources/lang/vi/admin/settings/general.php
#	resources/views/accessories/edit.blade.php
#	resources/views/hardware/view.blade.php
#	resources/views/layouts/default.blade.php
#	tests/api/ApiCategoriesCest.php
2019-11-18 19:49:39 -08:00

195 lines
5.1 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* 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) {
$view->with('snipeSettings', \App\Models\Setting::getSettings());
});
/**
* Set some common variables so that they're globally available.
* The paths should always be public (versus private uploads)
*/
// Model paths and URLs
\App::singleton('assets_upload_path', function(){
return 'assets/';
});
\App::singleton('accessories_upload_path', function() {
return 'accessories/';
});
\App::singleton('models_upload_path', function(){
return 'assetmodels/';
});
\App::singleton('models_upload_url', function(){
return 'assetmodels/';
});
// Categories
\App::singleton('categories_upload_path', function(){
return 'categories/';
});
\App::singleton('categories_upload_url', function(){
return 'categories/';
});
// Locations
\App::singleton('locations_upload_path', function(){
return 'locations/';
});
\App::singleton('locations_upload_url', function(){
return 'storage/public_uploads/locations/';
});
// Users
\App::singleton('users_upload_path', function(){
return 'users/';
});
\App::singleton('users_upload_url', function(){
return 'public_uploads/users/';
});
// Manufacturers
\App::singleton('manufacturers_upload_path', function(){
return 'manufacturers/';
});
\App::singleton('manufacturers_upload_url', function(){
return 'public_uploads/manufacturers/';
});
// Suppliers
\App::singleton('suppliers_upload_path', function(){
return 'suppliers/';
});
\App::singleton('suppliers_upload_url', function(){
return 'storage/public_uploads/suppliers/';
});
// Departments
\App::singleton('departments_upload_path', function(){
return 'departments/';
});
\App::singleton('departments_upload_url', function(){
return 'departments/';
});
// Company paths and URLs
\App::singleton('companies_upload_path', function(){
return 'companies/';
});
\App::singleton('companies_upload_url', function(){
return 'storage/public_uploads/companies/';
});
// Accessories paths and URLs
\App::singleton('accessories_upload_path', function(){
return public_path('/uploads/accessories/');
});
\App::singleton('accessories_upload_url', function(){
return url('/').'/uploads/accessories/';
});
// Consumables paths and URLs
\App::singleton('consumables_upload_path', function(){
return public_path('/uploads/consumables/');
});
\App::singleton('consumables_upload_url', function(){
return url('/').'/uploads/consumables/';
});
// Components paths and URLs
\App::singleton('components_upload_path', function(){
return public_path('/uploads/components/');
});
\App::singleton('components_upload_url', function(){
return url('/').'/uploads/components/';
});
// Accessories paths and URLs
\App::singleton('accessories_upload_path', function(){
return public_path('/uploads/accessories/');
});
\App::singleton('accessories_upload_url', function(){
return url('/').'/uploads/accessories/';
});
// Consumables paths and URLs
\App::singleton('consumables_upload_path', function(){
return public_path('/uploads/consumables/');
});
\App::singleton('consumables_upload_url', function(){
return url('/').'/uploads/consumables/';
});
// Components paths and URLs
\App::singleton('components_upload_path', function(){
return public_path('/uploads/components/');
});
\App::singleton('components_upload_url', function(){
return url('/').'/uploads/components/';
});
// 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'));
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
}