2017-11-06 21:17:17 -08:00
|
|
|
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
use Validator;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
use DB;
|
|
|
|
use Log;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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('models_upload_path', function(){
|
|
|
|
return public_path('/uploads/models/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('models_upload_url', function(){
|
2017-11-06 21:58:28 -08:00
|
|
|
return url('/').'/uploads/models/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Categories
|
|
|
|
\App::singleton('categories_upload_path', function(){
|
|
|
|
return public_path('/uploads/categories/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('categories_upload_url', function(){
|
2017-11-06 21:58:28 -08:00
|
|
|
return url('/').'/uploads/categories/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Locations
|
|
|
|
\App::singleton('locations_upload_path', function(){
|
|
|
|
return public_path('/uploads/locations/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('locations_upload_url', function(){
|
2017-11-06 21:58:28 -08:00
|
|
|
return url('/').'/uploads/locations/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Users
|
|
|
|
\App::singleton('users_upload_path', function(){
|
|
|
|
return public_path('/uploads/users/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('users_upload_url', function(){
|
2017-11-06 21:58:28 -08:00
|
|
|
return url('/').'/uploads/users/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Manufacturers
|
|
|
|
\App::singleton('manufacturers_upload_path', function(){
|
|
|
|
return public_path('/uploads/manufacturers/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('manufacturers_upload_url', function(){
|
2017-11-06 21:58:28 -08:00
|
|
|
return url('/').'/uploads/manufacturers/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Suppliers
|
|
|
|
\App::singleton('suppliers_upload_path', function(){
|
|
|
|
return public_path('/uploads/suppliers/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('suppliers_upload_url', function(){
|
2017-11-06 21:58:28 -08:00
|
|
|
return url('/').'/uploads/suppliers/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
// Departments
|
|
|
|
\App::singleton('departments_upload_path', function(){
|
|
|
|
return public_path('/uploads/departments/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('departments_upload_url', function(){
|
2017-11-06 21:58:28 -08:00
|
|
|
return url('/').'/uploads/departments/';
|
2017-11-06 21:17:17 -08:00
|
|
|
});
|
|
|
|
|
2017-11-07 11:28:13 -08:00
|
|
|
// Company paths and URLs
|
|
|
|
\App::singleton('companies_upload_path', function(){
|
|
|
|
return public_path('/uploads/companies/');
|
|
|
|
});
|
|
|
|
|
|
|
|
\App::singleton('companies_upload_url', function(){
|
|
|
|
return url('/').'/uploads/companies/';
|
|
|
|
});
|
|
|
|
|
2019-05-24 18:22:57 -07:00
|
|
|
// 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/';
|
|
|
|
});
|
|
|
|
|
2019-05-24 19:11:08 -07:00
|
|
|
// 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/';
|
|
|
|
});
|
|
|
|
|
2017-11-07 11:28:13 -08: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'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|