first upload all files
This commit is contained in:
148
app/Install/AdminAccount.php
Normal file
148
app/Install/AdminAccount.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Install;
|
||||
|
||||
use Modules\User\Entities\Role;
|
||||
use Modules\User\Entities\User;
|
||||
use Cartalyst\Sentinel\Laravel\Facades\Activation;
|
||||
|
||||
class AdminAccount
|
||||
{
|
||||
public function setup($data)
|
||||
{
|
||||
$role = Role::create(['name' => 'Admin', 'permissions' => $this->getAdminRolePermissions()]);
|
||||
|
||||
$admin = User::create([
|
||||
'first_name' => $data['first_name'],
|
||||
'last_name' => $data['last_name'],
|
||||
'email' => $data['email'],
|
||||
'phone' => $data['phone'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
|
||||
$activation = Activation::create($admin);
|
||||
Activation::complete($admin, $activation->code);
|
||||
|
||||
$admin->roles()->attach($role);
|
||||
}
|
||||
|
||||
private function getAdminRolePermissions()
|
||||
{
|
||||
return [
|
||||
// users
|
||||
'admin.users.index' => true,
|
||||
'admin.users.create' => true,
|
||||
'admin.users.edit' => true,
|
||||
'admin.users.destroy' => true,
|
||||
// roles
|
||||
'admin.roles.index' => true,
|
||||
'admin.roles.create' => true,
|
||||
'admin.roles.edit' => true,
|
||||
'admin.roles.destroy' => true,
|
||||
// products
|
||||
'admin.products.index' => true,
|
||||
'admin.products.create' => true,
|
||||
'admin.products.edit' => true,
|
||||
'admin.products.destroy' => true,
|
||||
// brands
|
||||
'admin.brands.index' => true,
|
||||
'admin.brands.create' => true,
|
||||
'admin.brands.edit' => true,
|
||||
'admin.brands.destroy' => true,
|
||||
// attributes
|
||||
'admin.attributes.index' => true,
|
||||
'admin.attributes.create' => true,
|
||||
'admin.attributes.edit' => true,
|
||||
'admin.attributes.destroy' => true,
|
||||
// attribute sets
|
||||
'admin.attribute_sets.index' => true,
|
||||
'admin.attribute_sets.create' => true,
|
||||
'admin.attribute_sets.edit' => true,
|
||||
'admin.attribute_sets.destroy' => true,
|
||||
// options
|
||||
'admin.options.index' => true,
|
||||
'admin.options.create' => true,
|
||||
'admin.options.edit' => true,
|
||||
'admin.options.destroy' => true,
|
||||
// filters
|
||||
'admin.filters.index' => true,
|
||||
'admin.filters.create' => true,
|
||||
'admin.filters.edit' => true,
|
||||
'admin.filters.destroy' => true,
|
||||
// reviews
|
||||
'admin.reviews.index' => true,
|
||||
'admin.reviews.create' => true,
|
||||
'admin.reviews.edit' => true,
|
||||
'admin.reviews.destroy' => true,
|
||||
// categories
|
||||
'admin.categories.index' => true,
|
||||
'admin.categories.create' => true,
|
||||
'admin.categories.edit' => true,
|
||||
'admin.categories.destroy' => true,
|
||||
// tags
|
||||
'admin.tags.index' => true,
|
||||
'admin.tags.create' => true,
|
||||
'admin.tags.edit' => true,
|
||||
'admin.tags.destroy' => true,
|
||||
// orders
|
||||
'admin.orders.index' => true,
|
||||
'admin.orders.show' => true,
|
||||
'admin.orders.edit' => true,
|
||||
// flash sales
|
||||
'admin.flash_sales.index' => true,
|
||||
'admin.flash_sales.create' => true,
|
||||
'admin.flash_sales.edit' => true,
|
||||
'admin.flash_sales.destroy' => true,
|
||||
// transactions
|
||||
'admin.transactions.index' => true,
|
||||
// coupons
|
||||
'admin.coupons.index' => true,
|
||||
'admin.coupons.create' => true,
|
||||
'admin.coupons.edit' => true,
|
||||
'admin.coupons.destroy' => true,
|
||||
// menus
|
||||
'admin.menus.index' => true,
|
||||
'admin.menus.create' => true,
|
||||
'admin.menus.edit' => true,
|
||||
'admin.menus.destroy' => true,
|
||||
'admin.menu_items.index' => true,
|
||||
'admin.menu_items.create' => true,
|
||||
'admin.menu_items.edit' => true,
|
||||
'admin.menu_items.destroy' => true,
|
||||
// Media
|
||||
'admin.media.index' => true,
|
||||
'admin.media.create' => true,
|
||||
'admin.media.destroy' => true,
|
||||
// pages
|
||||
'admin.pages.index' => true,
|
||||
'admin.pages.create' => true,
|
||||
'admin.pages.edit' => true,
|
||||
'admin.pages.destroy' => true,
|
||||
// currency rates
|
||||
'admin.currency_rates.index' => true,
|
||||
'admin.currency_rates.edit' => true,
|
||||
// tax
|
||||
'admin.taxes.index' => true,
|
||||
'admin.taxes.create' => true,
|
||||
'admin.taxes.edit' => true,
|
||||
'admin.taxes.destroy' => true,
|
||||
// translations
|
||||
'admin.translations.index' => true,
|
||||
'admin.translations.edit' => true,
|
||||
// appearance
|
||||
'admin.sliders.index' => true,
|
||||
'admin.sliders.create' => true,
|
||||
'admin.sliders.edit' => true,
|
||||
'admin.sliders.destroy' => true,
|
||||
// import
|
||||
'admin.importer.index' => true,
|
||||
'admin.importer.create' => true,
|
||||
// reports
|
||||
'admin.reports.index' => true,
|
||||
// settings
|
||||
'admin.settings.edit' => true,
|
||||
// storefront
|
||||
'admin.storefront.edit' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
111
app/Install/App.php
Normal file
111
app/Install/App.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Install;
|
||||
|
||||
use Modules\User\Entities\Role;
|
||||
use Modules\Setting\Entities\Setting;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Modules\Currency\Entities\CurrencyRate;
|
||||
use Jackiedo\DotenvEditor\Facades\DotenvEditor;
|
||||
|
||||
class App
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$this->generateAppKey();
|
||||
$this->setEnvVariables();
|
||||
$this->createCustomerRole();
|
||||
$this->setAppSettings();
|
||||
$this->createDefaultCurrencyRate();
|
||||
$this->createStorageFolder();
|
||||
}
|
||||
|
||||
private function generateAppKey()
|
||||
{
|
||||
Artisan::call('key:generate', ['--force' => true]);
|
||||
}
|
||||
|
||||
private function setEnvVariables()
|
||||
{
|
||||
$env = DotenvEditor::load();
|
||||
|
||||
$env->setKey('APP_ENV', 'production');
|
||||
$env->setKey('APP_DEBUG', 'false');
|
||||
$env->setKey('APP_CACHE', 'true');
|
||||
$env->setKey('APP_URL', url('/'));
|
||||
|
||||
$env->save();
|
||||
}
|
||||
|
||||
private function createCustomerRole()
|
||||
{
|
||||
Role::create(['name' => 'Customer']);
|
||||
}
|
||||
|
||||
private function setAppSettings()
|
||||
{
|
||||
Setting::setMany([
|
||||
'active_theme' => 'Storefront',
|
||||
'supported_countries' => ['BD'],
|
||||
'default_country' => 'BD',
|
||||
'supported_locales' => ['en'],
|
||||
'default_locale' => 'en',
|
||||
'default_timezone' => 'Asia/Dhaka',
|
||||
'customer_role' => 2,
|
||||
'reviews_enabled' => true,
|
||||
'auto_approve_reviews' => true,
|
||||
'cookie_bar_enabled' => true,
|
||||
'supported_currencies' => ['USD'],
|
||||
'default_currency' => 'USD',
|
||||
'send_order_invoice_email' => false,
|
||||
'store_email' => 'admin@fleetcart.test',
|
||||
'newsletter_enabled' => false,
|
||||
'search_engine' => 'mysql',
|
||||
'local_pickup_cost' => 0,
|
||||
'flat_rate_cost' => 0,
|
||||
'translatable' => [
|
||||
'store_name' => 'FleetCart',
|
||||
'free_shipping_label' => 'Free Shipping',
|
||||
'local_pickup_label' => 'Local Pickup',
|
||||
'flat_rate_label' => 'Flat Rate',
|
||||
'paypal_label' => 'PayPal',
|
||||
'paypal_description' => 'Pay via your PayPal account.',
|
||||
'stripe_label' => 'Stripe',
|
||||
'stripe_description' => 'Pay via credit or debit card.',
|
||||
'paytm_label' => 'Paytm',
|
||||
'paytm_description' => 'The best payment gateway provider in India for e-payment through credit card, debit card & net banking.',
|
||||
'razorpay_label' => 'Razorpay',
|
||||
'razorpay_description' => 'Pay securely by Credit or Debit card or Internet Banking through Razorpay.',
|
||||
'instamojo_label' => 'Instamojo',
|
||||
'instamojo_description' => 'CC/DB/NB/Wallets',
|
||||
'authorizenet_label' => 'Authorize.net',
|
||||
'authorizenet_description' => 'Accept payments anytime, anywhere',
|
||||
'paystack_label' => 'Paystack',
|
||||
'paystack_description' => 'Modern online and offline payments for Africa',
|
||||
'flutterwave_label' => 'Flutterwave',
|
||||
'flutterwave_description' => 'Endless possibilities for every business',
|
||||
'mercadopago_label' => 'Mercado Pago',
|
||||
'mercadopago_description' => 'From now on, do more with your money',
|
||||
'cod_label' => 'Cash On Delivery',
|
||||
'cod_description' => 'Pay with cash upon delivery.',
|
||||
'bank_transfer_label' => 'Bank Transfer',
|
||||
'bank_transfer_description' => 'Make your payment directly into our bank account. Please use your Order ID as the payment reference.',
|
||||
'check_payment_label' => 'Check / Money Order',
|
||||
'check_payment_description' => 'Please send a check to our store.',
|
||||
],
|
||||
'storefront_copyright_text' => 'Copyright © <a href="{{ store_url }}">{{ store_name }}</a> {{ year }}. All rights reserved.',
|
||||
]);
|
||||
}
|
||||
|
||||
private function createDefaultCurrencyRate()
|
||||
{
|
||||
CurrencyRate::create(['currency' => 'USD', 'rate' => 1]);
|
||||
}
|
||||
|
||||
private function createStorageFolder()
|
||||
{
|
||||
if (!is_dir(public_path('storage'))) {
|
||||
mkdir(public_path('storage'));
|
||||
}
|
||||
}
|
||||
}
|
||||
55
app/Install/Database.php
Normal file
55
app/Install/Database.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Install;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Jackiedo\DotenvEditor\Facades\DotenvEditor;
|
||||
|
||||
class Database
|
||||
{
|
||||
public function setup($data)
|
||||
{
|
||||
$this->checkDatabaseConnection($data);
|
||||
$this->setEnvVariables($data);
|
||||
$this->migrateDatabase();
|
||||
}
|
||||
|
||||
private function checkDatabaseConnection($data)
|
||||
{
|
||||
$this->setupDatabaseConnectionConfig($data);
|
||||
|
||||
DB::connection('mysql')->reconnect();
|
||||
DB::connection('mysql')->getPdo();
|
||||
}
|
||||
|
||||
private function setupDatabaseConnectionConfig($data)
|
||||
{
|
||||
config([
|
||||
'database.default' => 'mysql',
|
||||
'database.connections.mysql.host' => $data['host'],
|
||||
'database.connections.mysql.port' => $data['port'],
|
||||
'database.connections.mysql.database' => $data['database'],
|
||||
'database.connections.mysql.username' => $data['username'],
|
||||
'database.connections.mysql.password' => $data['password'],
|
||||
]);
|
||||
}
|
||||
|
||||
private function setEnvVariables($data)
|
||||
{
|
||||
$env = DotenvEditor::load();
|
||||
|
||||
$env->setKey('DB_HOST', $data['host']);
|
||||
$env->setKey('DB_PORT', $data['port']);
|
||||
$env->setKey('DB_DATABASE', $data['database']);
|
||||
$env->setKey('DB_USERNAME', $data['username']);
|
||||
$env->setKey('DB_PASSWORD', $data['password']);
|
||||
|
||||
$env->save();
|
||||
}
|
||||
|
||||
private function migrateDatabase()
|
||||
{
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
}
|
||||
}
|
||||
39
app/Install/Requirement.php
Normal file
39
app/Install/Requirement.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Install;
|
||||
|
||||
class Requirement
|
||||
{
|
||||
public function extensions()
|
||||
{
|
||||
return [
|
||||
'PHP >= 8.0.2' => version_compare(phpversion(), '8.0.2'),
|
||||
'Intl PHP Extension' => extension_loaded('intl'),
|
||||
'OpenSSL PHP Extension' => extension_loaded('openssl'),
|
||||
'PDO PHP Extension' => extension_loaded('pdo'),
|
||||
'Mbstring PHP Extension' => extension_loaded('mbstring'),
|
||||
'Tokenizer PHP Extension' => extension_loaded('tokenizer'),
|
||||
'XML PHP Extension' => extension_loaded('xml'),
|
||||
'Ctype PHP Extension' => extension_loaded('ctype'),
|
||||
'JSON PHP Extension' => extension_loaded('json'),
|
||||
];
|
||||
}
|
||||
|
||||
public function directories()
|
||||
{
|
||||
return [
|
||||
'.env' => is_writable(base_path('.env')),
|
||||
'storage' => is_writable(storage_path()),
|
||||
'bootstrap/cache' => is_writable(app()->bootstrapPath('cache')),
|
||||
];
|
||||
}
|
||||
|
||||
public function satisfied()
|
||||
{
|
||||
return collect($this->extensions())
|
||||
->merge($this->directories())
|
||||
->every(function ($item) {
|
||||
return $item;
|
||||
});
|
||||
}
|
||||
}
|
||||
22
app/Install/Store.php
Normal file
22
app/Install/Store.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace FleetCart\Install;
|
||||
|
||||
use Modules\Setting\Entities\Setting;
|
||||
|
||||
class Store
|
||||
{
|
||||
public function setup($data)
|
||||
{
|
||||
Setting::setMany([
|
||||
'translatable' => [
|
||||
'store_name' => $data['store_name'],
|
||||
],
|
||||
'store_email' => $data['store_email'],
|
||||
'store_phone' => $data['store_phone'],
|
||||
'search_engine' => $data['search_engine'],
|
||||
'algolia_app_id' => $data['algolia_app_id'],
|
||||
'algolia_secret' => $data['algolia_secret'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user