добавлен авторищация по api, экспорт и импорт продуктов

This commit is contained in:
abdurahman 2024-01-08 17:13:13 +05:00
parent c08b36d1b6
commit af1e381ca0
14 changed files with 906 additions and 434 deletions

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('api_tokens', function (Blueprint $table) {
$table->id();
$table->integer('user_id')->nullable()->unsigned();
$table->string('token');
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('api_tokens');
}
};

View File

@ -0,0 +1,13 @@
<?php
namespace Modules\Api\Entities;
use Carbon\Carbon;
use Modules\Support\Eloquent\Model;
use Illuminate\Support\Str;
class ApiToken extends Model{
protected $fillable = ['user_id', 'token'];
public $timestamps = false;
}

View File

@ -0,0 +1,46 @@
<?php
namespace Modules\Api\Http\Controllers;
use Carbon\Carbon;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Modules\Api\Entities\ApiToken;
use Modules\Api\Http\Requests\ApiAuthRequest;
use Modules\User\Entities\User;
class ApiAuthController extends Controller {
public function login(ApiAuthRequest $request)
{
$user = User::findByEmail($request->email);
if (Auth::guard()->attempt($request->validated()) && $user->hasRoleName('admin')) {
$apiToken = ApiToken::create([
'token' => 'apit_' . Str::random() . md5(Carbon::now()->toString()),
'user_id' => $user->id,
]);
return response([
'token' => $apiToken,
]);
}
return response()->json([
'status' => 'Unauthorized.'
], 401);
}
public function logout() {
$token = request()->header('authorization');
ApiToken::query()
->where('token', $token)
->delete();
return response()->json([
'status' => 'success'
]);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Modules\Api\Http\Controllers;
use Illuminate\Support\Facades\Response;
use Illuminate\Routing\Controller;
use Modules\Product\Entities\Product;
class ExportProductController extends Controller {
public function __invoke()
{
$products = Product::with('categories')->get();
return response()->json($products);
}
}

View File

@ -0,0 +1,171 @@
<?php
namespace Modules\Api\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Modules\Api\Http\Requests\ImportProductRequest;
use Modules\Brand\Entities\Brand;
use Modules\Brand\Entities\BrandTranslation;
use Modules\Category\Entities\Category;
use Modules\Category\Entities\CategoryTranslation;
use Modules\Media\Entities\File;
use Modules\Meta\Entities\MetaData;
use Modules\Meta\Entities\MetaDataTranslation;
use Modules\Product\Entities\Product;
class ImportProductController extends Controller {
public function __invoke(ImportProductRequest $request)
{
foreach ($request->data as $data) {
$file = $this->getFilesFromUrl($data['image']);
$product = Product::create($data + [
'brand_id' => $this->getBrandId($data['brand']),
]) ;
$this->createMeta($data['seo'] ?? [], Product::class, $product->id);
$product->files()->attach([$file->id => ['zone' => 'base_image']]);
$product->categories()->attach($this->getCategories($data['categories']));
}
return response()->json([
'status' => 'success'
]);
}
private function getCategories($productCategories) {
$categories = [];
foreach ($productCategories as $productCategory) {
$parendId = null;
foreach ($productCategory as $category) {
$parendId = $this->getCategoryFromName($category, $parendId);
}
$categories[] = $parendId;
}
return $categories;
}
private function getCategoryFromName($data, $parendId) {
$category = CategoryTranslation::where([
'name' => $data['name'],
'locale' => 'en'
])->first();
if (!empty($category)) {
return $category->category_id;
}
$category = new Category();
$category->name = $data['name'];
$category->is_active = true;
$category->is_searchable = true;
$category->parent_id = $parendId;
$category->save();
if (isset($data['image']['logo']) && !empty($data['image']['logo'])) {
$this->createLogo($data['image']['logo'], $category, Category::class);
}
if (isset($data['image']['banner']) && !empty($data['image']['banner'])) {
$this->createBanner($data['image']['banner'], $category, Category::class);
}
return $category->id;
}
private function getBrandId($data) {
// dd($data);
$brand = BrandTranslation::where([
'name' => $data['name'],
'locale' => 'en'
])->first();
if (!empty($brand)) {
return $brand->brand_id;
}
$brand = new Brand();
$brand->name = $data['name'];
$brand->is_active = true;
$brand->save();
$this->createMeta($data['seo'] ?? [], Brand::class, $brand->id);
if (isset($data['image']['logo']) && !empty($data['image']['logo'])) {
$this->createLogo($data['image']['logo'], $brand, Brand::class);
}
if (isset($data['image']['banner']) && !empty($data['image']['banner'])) {
$this->createBanner($data['image']['banner'], $brand, Brand::class);
}
return $brand->id;
}
private function getFilesFromUrl($imageUrl) {
$headers = get_headers($imageUrl, 1);
$fileContents = file_get_contents($imageUrl);
$path = 'media/' . time() . Str::random(6) . '.' . pathinfo($imageUrl, PATHINFO_EXTENSION);
Storage::put($path, $fileContents);
return File::create([
'user_id' => 1,
'disk' => config('filesystems.default'),
'filename' => pathinfo($imageUrl, PATHINFO_BASENAME),
'path' => $path,
'extension' => pathinfo($imageUrl, PATHINFO_EXTENSION) ?? '',
'mime' => $headers['Content-Type'],
'size' => strlen($fileContents),
]);
}
private function createMeta($seo, $class, $id) {
$metaData = new MetaDataTranslation();
$metaData->meta_title = isset($seo['title']) ? $seo['title'] : '';
$metaData->meta_description = isset($seo['description']) ? $seo['description'] : '';
$metaData->locale = 'en';
$metaData->meta_data_id = $this->getMetaId($class, $id);
$metaData->save();
}
private function getMetaId($class, $id) {
$meta = MetaData::where([
'entity_type' => $class,
'entity_id' => $id,
])->first();
if (!empty($meta)) {
return $meta->id;
}
$meta = new MetaData();
$meta->entity_type = $class;
$meta->entity_id = $id;
$meta->save();
return $meta->id;
}
private function createLogo($url, $class, $className) {
$file = $this->getFilesFromUrl($url);
$class->files()->attach([$file->id => ['zone' => 'logo']]);
}
private function createBanner($url, $class, $className) {
$file = $this->getFilesFromUrl($url);
$class->files()->attach([$file->id => ['zone' => 'banner']]);
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace Modules\Api\Http\Middleware;
use Carbon\Carbon;
use Closure;
use Illuminate\Http\Request;
use Modules\Api\Entities\ApiToken;
class ApiAuthorization
{
/**
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string $permission
* @param string $to
* @return \Illuminate\Http\Response
*/
public function handle(Request $request, Closure $next)
{
if ($this->hasAccess($request)) {
return $next($request);
}
return $this->handleUnauthorizedRequest($request);
}
/**
* @param \Illuminate\Http\Request $request
* @param string $permission
* @return \Illuminate\Http\Response
*/
private function handleUnauthorizedRequest(Request $request)
{
return response()->json([
'status' => 'Unauthorized.'
], 401);
}
private function hasAccess(Request $request)
{
$token = $request->header('authorization');
$hasToken = ApiToken::query()
->where('token', $token)
->exists();
if (!empty($token) && $hasToken) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Modules\Api\Http\Requests;
use Illuminate\Validation\Rule;
use Modules\Product\Entities\Product;
use Modules\Core\Http\Requests\Request;
class ApiAuthRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => ['required', 'email', Rule::exists('users', 'email')],
'password' => 'required',
];
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace Modules\Api\Http\Requests;
use Illuminate\Validation\Rule;
use Modules\Product\Entities\Product;
use Modules\Core\Http\Requests\Request;
class ImportProductRequest extends Request
{
/**
* Available attributes.
*
* @var string
*/
protected $availableAttributes = 'product::attributes';
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
// 'slug' => $this->getSlugRules(),
'data' => 'required|array|min:1',
'data.*.slug' => 'sometimes',
'data.*.name' => 'required',
'data.*.description' => 'required',
'data.*.brand' => 'required|array|min:1',
'data.*.brand.name' => 'required|string',
'data.*.brand.seo' => 'sometimes',
'data.*.brand.image' => 'sometimes',
'data.*.tax_class_id' => ['nullable', Rule::exists('tax_classes', 'id')],
'data.*.is_virtual' => 'required|boolean',
'data.*.is_active' => 'required|boolean',
'data.*.price' => 'required|numeric|min:0|max:99999999999999',
'data.*.special_price' => 'nullable|numeric|min:0|max:99999999999999',
'data.*.special_price_type' => ['nullable', Rule::in(['fixed', 'percent'])],
'data.*.special_price_start' => 'nullable|date',
'data.*.special_price_end' => 'nullable|date',
'data.*.manage_stock' => 'required|boolean',
'data.*.qty' => 'required_if:manage_stock,1|nullable|numeric',
'data.*.in_stock' => 'required|boolean',
'data.*.new_from' => 'nullable|date',
'data.*.new_to' => 'nullable|date',
'data.*.categories' => 'required|array|min:1',
'data.*.categories.*.*.name' => 'required|string',
'data.*.categories.*.*.seo' => 'sometimes',
'data.*.image' => 'required|string',
];
}
// private function getSlugRules()
// {
// $rules = $this->route()->getName() === 'admin.products.update' ? ['required'] : ['sometimes'];
// $slug = Product::withoutGlobalScope('active')
// ->where('id', $this->id)
// ->value('slug');
// $rules[] = Rule::unique('products', 'slug')->ignore($slug, 'slug');
// return $rules;
// }
}

View File

@ -0,0 +1,18 @@
<?php
namespace Modules\Api\Providers;
use Illuminate\Support\ServiceProvider;
class ApiProvider extends ServiceProvider
{
public function register()
{
}
public function boot()
{
$this->loadRoutesFrom(__DIR__ . '/../Routes/admin.php');
$this->loadRoutesFrom(__DIR__ . '/../Routes/public.php');
}
}

View File

@ -0,0 +1,9 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Api\Http\Controllers\ApiAuthController;
Route::prefix('api')->group(function () {
Route::post('/login', [ApiAuthController::class, 'login'])->name('api.auth.login');
Route::post('/logout', [ApiAuthController::class, 'logout'])->middleware('api_auth')->name('api.auth.logout');
});

View File

@ -0,0 +1,14 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Api\Http\Controllers\ExportProductController;
use Modules\Api\Http\Controllers\ImportProductController;
Route::group(['prefix' => 'export', 'middleware' => 'api_auth'], function () {
Route::get('products', ExportProductController::class)->name('api.export.products');
});
Route::group(['prefix' => 'import', 'middleware' => 'api_auth'], function () {
Route::post('products', ImportProductController::class)->name('api.import.products');
});

View File

@ -0,0 +1,3 @@
{
}

View File

@ -1,203 +1,204 @@
<?php
namespace Modules\Core\Providers;
use Exception;
use Modules\Support\Locale;
use Modules\Setting\Entities\Setting;
use Illuminate\Support\ServiceProvider;
use Modules\Setting\Repository as SettingRepository;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
class CoreServiceProvider extends ServiceProvider
{
/**
* Core module specific middleware.
*
* @var array
*/
protected $middleware = [
'auth' => \Modules\Core\Http\Middleware\Authenticate::class,
'admin' => \Modules\Core\Http\Middleware\AdminMiddleware::class,
'guest' => \Modules\Core\Http\Middleware\GuestMiddleware::class,
'can' => \Modules\Core\Http\Middleware\Authorization::class,
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
'locale_session_redirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
'localization_redirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
];
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if (! config('app.installed')) {
return;
}
$this->setupSupportedLocales();
$this->registerSetting();
$this->setupAppLocale();
$this->setupAppCacheDriver();
$this->hideDefaultLocaleInURL();
$this->setupAppTimezone();
$this->setupMailConfig();
$this->registerMiddleware();
$this->registerInAdminPanelState();
$this->blacklistAdminRoutesOnFrontend();
}
/**
* Setup supported locales.
*
* @return void
*/
private function setupSupportedLocales()
{
$supportedLocales = [];
foreach ($this->getSupportedLocales() as $locale) {
$supportedLocales[$locale]['name'] = Locale::name($locale);
}
$this->app['config']->set('laravellocalization.supportedLocales', $supportedLocales);
}
/**
* Get supported locales from database.
*
* @return array
*/
private function getSupportedLocales()
{
try {
return Setting::get('supported_locales', [config('app.locale')]);
} catch (Exception $e) {
return [config('app.locale')];
}
}
/**
* Hide default locale in url for non multi-locale mode.
*
* @return void
*/
private function hideDefaultLocaleInURL()
{
if (! is_multilingual()) {
$this->app['config']->set('laravellocalization.hideDefaultLocaleInURL', true);
}
}
/**
* Register setting binding.
*
* @return void
*/
private function registerSetting()
{
$this->app->singleton('setting', function () {
return new SettingRepository(Setting::allCached());
});
}
/**
* Setup application locale.
*
* @return string
*/
private function setupAppLocale()
{
$this->app['config']->set('app.locale', $defaultLocale = Setting::get('default_locale'));
$this->app['config']->set('app.fallback_locale', $defaultLocale);
$locale = is_null(LaravelLocalization::setLocale()) ? $defaultLocale : null;
LaravelLocalization::setLocale($locale);
}
/**
* Setup application cache driver.
*
* @return void
*/
private function setupAppCacheDriver()
{
$this->app['config']->set('cache.default', config('app.cache') ? 'file' : 'array');
}
/**
* Setup application timezone.
*
* @return void
*/
private function setupAppTimezone()
{
$timezone = setting('default_timezone') ?? config('app.timezone');
date_default_timezone_set($timezone);
$this->app['config']->set('app.timezone', $timezone);
}
/**
* Setup application mail config.
*
* @return void
*/
private function setupMailConfig()
{
$this->app['config']->set('mail.default', 'smtp');
$this->app['config']->set('mail.from.address', setting('mail_from_address'));
$this->app['config']->set('mail.from.name', setting('mail_from_name'));
$this->app['config']->set('mail.mailers.smtp.host', setting('mail_host'));
$this->app['config']->set('mail.mailers.smtp.port', setting('mail_port'));
$this->app['config']->set('mail.mailers.smtp.username', setting('mail_username'));
$this->app['config']->set('mail.mailers.smtp.password', setting('mail_password'));
$this->app['config']->set('mail.mailers.smtp.encryption', setting('mail_encryption'));
}
/**
* Register the filters.
*
* @return void
*/
private function registerMiddleware()
{
foreach ($this->middleware as $name => $middleware) {
$this->app['router']->aliasMiddleware($name, $middleware);
}
}
/**
* Register inAdminPanel state to the IoC container.
*
* @return void
*/
private function registerInAdminPanelState()
{
if ($this->app->runningInConsole()) {
return $this->app['inAdminPanel'] = false;
}
$index = in_array($this->app['request']->segment(1), setting('supported_locales'))
? 2
: 1;
$this->app['inAdminPanel'] = $this->app['request']->segment($index) === 'admin';
}
/**
* Blacklist admin routes on frontend for ziggy package.
*
* @return void
*/
private function blacklistAdminRoutesOnFrontend()
{
if (! $this->app['inAdminPanel']) {
$this->app['config']->set('ziggy.blacklist', ['admin.*']);
}
}
}
<?php
namespace Modules\Core\Providers;
use Exception;
use Modules\Support\Locale;
use Modules\Setting\Entities\Setting;
use Illuminate\Support\ServiceProvider;
use Modules\Setting\Repository as SettingRepository;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
class CoreServiceProvider extends ServiceProvider
{
/**
* Core module specific middleware.
*
* @var array
*/
protected $middleware = [
'auth' => \Modules\Core\Http\Middleware\Authenticate::class,
'admin' => \Modules\Core\Http\Middleware\AdminMiddleware::class,
'guest' => \Modules\Core\Http\Middleware\GuestMiddleware::class,
'can' => \Modules\Core\Http\Middleware\Authorization::class,
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
'locale_session_redirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
'localization_redirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
'api_auth' => \Modules\Api\Http\Middleware\ApiAuthorization::class,
];
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if (! config('app.installed')) {
return;
}
$this->setupSupportedLocales();
$this->registerSetting();
$this->setupAppLocale();
$this->setupAppCacheDriver();
$this->hideDefaultLocaleInURL();
$this->setupAppTimezone();
$this->setupMailConfig();
$this->registerMiddleware();
$this->registerInAdminPanelState();
$this->blacklistAdminRoutesOnFrontend();
}
/**
* Setup supported locales.
*
* @return void
*/
private function setupSupportedLocales()
{
$supportedLocales = [];
foreach ($this->getSupportedLocales() as $locale) {
$supportedLocales[$locale]['name'] = Locale::name($locale);
}
$this->app['config']->set('laravellocalization.supportedLocales', $supportedLocales);
}
/**
* Get supported locales from database.
*
* @return array
*/
private function getSupportedLocales()
{
try {
return Setting::get('supported_locales', [config('app.locale')]);
} catch (Exception $e) {
return [config('app.locale')];
}
}
/**
* Hide default locale in url for non multi-locale mode.
*
* @return void
*/
private function hideDefaultLocaleInURL()
{
if (! is_multilingual()) {
$this->app['config']->set('laravellocalization.hideDefaultLocaleInURL', true);
}
}
/**
* Register setting binding.
*
* @return void
*/
private function registerSetting()
{
$this->app->singleton('setting', function () {
return new SettingRepository(Setting::allCached());
});
}
/**
* Setup application locale.
*
* @return string
*/
private function setupAppLocale()
{
$this->app['config']->set('app.locale', $defaultLocale = Setting::get('default_locale'));
$this->app['config']->set('app.fallback_locale', $defaultLocale);
$locale = is_null(LaravelLocalization::setLocale()) ? $defaultLocale : null;
LaravelLocalization::setLocale($locale);
}
/**
* Setup application cache driver.
*
* @return void
*/
private function setupAppCacheDriver()
{
$this->app['config']->set('cache.default', config('app.cache') ? 'file' : 'array');
}
/**
* Setup application timezone.
*
* @return void
*/
private function setupAppTimezone()
{
$timezone = setting('default_timezone') ?? config('app.timezone');
date_default_timezone_set($timezone);
$this->app['config']->set('app.timezone', $timezone);
}
/**
* Setup application mail config.
*
* @return void
*/
private function setupMailConfig()
{
$this->app['config']->set('mail.default', 'smtp');
$this->app['config']->set('mail.from.address', setting('mail_from_address'));
$this->app['config']->set('mail.from.name', setting('mail_from_name'));
$this->app['config']->set('mail.mailers.smtp.host', setting('mail_host'));
$this->app['config']->set('mail.mailers.smtp.port', setting('mail_port'));
$this->app['config']->set('mail.mailers.smtp.username', setting('mail_username'));
$this->app['config']->set('mail.mailers.smtp.password', setting('mail_password'));
$this->app['config']->set('mail.mailers.smtp.encryption', setting('mail_encryption'));
}
/**
* Register the filters.
*
* @return void
*/
private function registerMiddleware()
{
foreach ($this->middleware as $name => $middleware) {
$this->app['router']->aliasMiddleware($name, $middleware);
}
}
/**
* Register inAdminPanel state to the IoC container.
*
* @return void
*/
private function registerInAdminPanelState()
{
if ($this->app->runningInConsole()) {
return $this->app['inAdminPanel'] = false;
}
$index = in_array($this->app['request']->segment(1), setting('supported_locales'))
? 2
: 1;
$this->app['inAdminPanel'] = $this->app['request']->segment($index) === 'admin';
}
/**
* Blacklist admin routes on frontend for ziggy package.
*
* @return void
*/
private function blacklistAdminRoutesOnFrontend()
{
if (! $this->app['inAdminPanel']) {
$this->app['config']->set('ziggy.blacklist', ['admin.*']);
}
}
}

View File

@ -1,231 +1,232 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
*/
'name' => env('APP_NAME', 'FleetCart'),
'installed' => env('APP_INSTALLED', false),
/*
|--------------------------------------------------------------------------
| Application cache
|--------------------------------------------------------------------------
| Set this to true to use the cache decorators, this will greatly improve
| the application speed and performance
*/
'cache' => env('APP_CACHE', false),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
FleetCart\Providers\AppServiceProvider::class,
FleetCart\Providers\RouteServiceProvider::class,
Nwidart\Modules\LaravelModulesServiceProvider::class,
Mehedi\Stylist\StylistServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Module' => \Nwidart\Modules\Facades\Module::class,
],
];
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
*/
'name' => env('APP_NAME', 'FleetCart'),
'installed' => env('APP_INSTALLED', false),
/*
|--------------------------------------------------------------------------
| Application cache
|--------------------------------------------------------------------------
| Set this to true to use the cache decorators, this will greatly improve
| the application speed and performance
*/
'cache' => env('APP_CACHE', false),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
FleetCart\Providers\AppServiceProvider::class,
FleetCart\Providers\RouteServiceProvider::class,
Nwidart\Modules\LaravelModulesServiceProvider::class,
Mehedi\Stylist\StylistServiceProvider::class,
Modules\Api\Providers\ApiProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Module' => \Nwidart\Modules\Facades\Module::class,
],
];