Merge 'bagisto/master' into introduce-company-name-and-sales-tax-id-columns

This commit is contained in:
Florian Bosdorff 2020-01-28 08:15:11 +01:00
commit 5188b1b7f9
35 changed files with 277 additions and 120 deletions

View File

@ -13,6 +13,7 @@ DB_PORT=3306
DB_DATABASE=bagisto_testing
DB_USERNAME=bagisto
DB_PASSWORD=secret
DB_PREFIX=
BROADCAST_DRIVER=log
CACHE_DRIVER=file

View File

@ -61,6 +61,7 @@ class GenerateProducts extends Command
try {
$result = $this->generateProduct->create();
} catch (\Exception $e) {
report($e);
continue;
}

View File

@ -122,7 +122,7 @@ class CustomerController extends Controller
try {
Mail::queue(new NewCustomerNotification($customer, $password));
} catch (\Exception $e) {
report($e);
}
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Customer']));

View File

@ -10,13 +10,15 @@ use Webkul\Admin\Mail\NewShipmentNotification;
use Webkul\Admin\Mail\NewInventorySourceNotification;
use Webkul\Admin\Mail\CancelOrderNotification;
use Webkul\Admin\Mail\NewRefundNotification;
/**
* Order event handler
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class Order {
class Order
{
/**
* @param mixed $order
@ -30,7 +32,7 @@ class Order {
Mail::queue(new NewAdminNotification($order));
} catch (\Exception $e) {
report($e);
}
}
@ -42,12 +44,13 @@ class Order {
public function sendNewInvoiceMail($invoice)
{
try {
if ($invoice->email_sent)
if ($invoice->email_sent) {
return;
}
Mail::queue(new NewInvoiceNotification($invoice));
} catch (\Exception $e) {
report($e);
}
}
@ -61,7 +64,7 @@ class Order {
try {
Mail::queue(new NewRefundNotification($refund));
} catch (\Exception $e) {
report($e);
}
}
@ -73,25 +76,28 @@ class Order {
public function sendNewShipmentMail($shipment)
{
try {
if ($shipment->email_sent)
if ($shipment->email_sent) {
return;
}
Mail::queue(new NewShipmentNotification($shipment));
Mail::queue(new NewInventorySourceNotification($shipment));
} catch (\Exception $e) {
report($e);
}
}
/*
/**
* @param mixed $order
* */
public function sendCancelOrderMail($order){
try{
*
*/
public function sendCancelOrderMail($order)
{
try {
Mail::queue(new CancelOrderNotification($order));
}catch (\Exception $e){
\Log::error('Error occured when sending email '.$e->getMessage());
} catch (\Exception $e) {
report($e);
}
}
}

View File

@ -167,6 +167,7 @@ class AttributeController extends Controller
$this->attributeRepository->delete($value);
}
} catch (\Exception $e) {
report($e);
$suppressFlash = true;
continue;

View File

@ -154,7 +154,8 @@ class AttributeFamilyController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
session()->flash('error', trans( 'admin::app.response.delete-failed', ['name' => 'Family']));
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Family']));
}
}
@ -177,16 +178,18 @@ class AttributeFamilyController extends Controller
try {
$this->attributeFamilyRepository->delete($value);
} catch (\Exception $e) {
report($e);
$suppressFlash = true;
continue;
}
}
if (! $suppressFlash)
if (!$suppressFlash) {
session()->flash('success', ('admin::app.datagrid.mass-ops.delete-success'));
else
} else {
session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'Attribute Family']));
}
return redirect()->back();
} else {

View File

@ -65,7 +65,7 @@ class CatalogRuleIndex
$this->catalogRuleProductPriceHelper->indexRuleProductPrice(1000);
} catch (\Exception $e) {
report($e);
}
}
@ -80,7 +80,7 @@ class CatalogRuleIndex
try {
if (! $product->getTypeInstance()->priceRuleCanBeApplied())
return;
$productIds = $product->getTypeInstance()->isComposite()
? $product->getTypeInstance()->getChildrenIds()
: [$product->id];
@ -93,7 +93,7 @@ class CatalogRuleIndex
$this->catalogRuleProductPriceHelper->indexRuleProductPrice(1000, $product);
} catch (\Exception $e) {
report($e);
}
}

View File

@ -0,0 +1,52 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddApiTokenColumns extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// @see https://laravel.com/docs/6.x/api-authentication#database-preparation
Schema::table('customers', function ($table) {
$table
->string('api_token', 80)
->after('password')
->unique()
->nullable()
->default(null);
});
Schema::table('admins', function ($table) {
$table
->string('api_token', 80)
->after('password')
->unique()
->nullable()
->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('api_token');
});
Schema::table('admins', function (Blueprint $table) {
$table->dropColumn('api_token');
});
}
}

View File

@ -144,6 +144,7 @@ class CurrencyController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Currency']));
}
}

View File

@ -200,6 +200,7 @@ class ExchangeRateController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-error', ['name' => 'Exchange rate']));
}
}

View File

@ -104,6 +104,7 @@ class SubscriptionController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Subscriber']));
}

View File

@ -17,8 +17,9 @@ $factory->define(CustomerAddress::class, function (Faker $faker) {
return factory(Customer::class)->create()->id;
},
'company_name' => $faker->company,
'name' => $faker->name,
'vat_id' => $fakerIt->vatId(),
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'address1' => $faker->streetAddress,
'country' => $faker->countryCode,
'state' => $faker->state,

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNewColumnAndRenameNameColumnInCustomerAddressesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('customer_addresses', function (Blueprint $table) {
$table->renameColumn('name', 'first_name')->nullable();
});
Schema::table('customer_addresses', function (Blueprint $table) {
$table->string('last_name')->after('first_name')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customer_addresses', function (Blueprint $table) {
//
});
}
}

View File

@ -89,6 +89,8 @@ class AddressController extends Controller
]);
$cust_id['customer_id'] = $this->customer->id;
$cust_id['first_name'] = $this->customer->first_name;
$cust_id['last_name'] = $this->customer->last_name;
$data = array_merge($cust_id, $data);
if ($this->customer->addresses->count() == 0) {

View File

@ -71,6 +71,7 @@ class ForgotPasswordController extends Controller
['email' => trans($response)]
);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans($e->getMessage()));
return redirect()->back();

View File

@ -2,6 +2,8 @@
namespace Webkul\Customer\Http\Controllers;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;
use Webkul\Customer\Mail\RegistrationEmail;
@ -85,6 +87,7 @@ class RegistrationController extends Controller
$data = request()->input();
$data['password'] = bcrypt($data['password']);
$data['api_token'] = Str::random(80);
if (core()->getConfigData('customer.settings.email.verification')) {
$data['is_verified'] = 0;
@ -111,18 +114,19 @@ class RegistrationController extends Controller
session()->flash('success', trans('shop::app.customer.signup-form.success-verify'));
} catch (\Exception $e) {
report($e);
session()->flash('info', trans('shop::app.customer.signup-form.success-verify-email-unsent'));
}
} else {
try {
try {
Mail::queue(new RegistrationEmail(request()->all()));
session()->flash('success', trans('shop::app.customer.signup-form.success-verify')); //customer registered successfully
} catch (\Exception $e) {
report($e);
session()->flash('info', trans('shop::app.customer.signup-form.success-verify-email-unsent'));
}
session()->flash('success', trans('shop::app.customer.signup-form.success'));
}
@ -174,6 +178,7 @@ class RegistrationController extends Controller
\Cookie::queue(\Cookie::forget('email-for-resend'));
}
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('shop::app.customer.signup-form.verification-not-sent'));
return redirect()->back();

View File

@ -172,6 +172,7 @@ class WishlistController extends Controller
return redirect()->back();
} catch (\Exception $e) {
report($e);
session()->flash('warning', $e->getMessage());
return redirect()->route('shop.productOrCategory.index', $wishlistItem->product->url_key);

View File

@ -17,9 +17,9 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject
protected $table = 'customers';
protected $fillable = ['first_name', 'last_name', 'gender', 'date_of_birth', 'email', 'phone', 'password', 'customer_group_id', 'subscribed_to_news_letter', 'is_verified', 'token', 'notes', 'status'];
protected $fillable = ['first_name', 'last_name', 'gender', 'date_of_birth', 'email', 'phone', 'password', 'api_token', 'customer_group_id', 'subscribed_to_news_letter', 'is_verified', 'token', 'notes', 'status'];
protected $hidden = ['password', 'remember_token'];
protected $hidden = ['password', 'api_token', 'remember_token'];
/**
* Get the customer full name.

View File

@ -20,6 +20,16 @@ class CustomerAddress extends Model implements CustomerAddressContract
'city',
'postcode',
'phone',
'default_address',
'default_address',
'first_name',
'last_name',
];
/**
* Get the customer address full name.
*/
public function getNameAttribute()
{
return $this->first_name . ' ' . $this->last_name;
}
}

View File

@ -168,6 +168,7 @@ class InventorySourceController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Inventory source']));
}
}

View File

@ -245,6 +245,7 @@ class ProductController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Product']));
}

View File

@ -105,6 +105,7 @@ class ReviewController extends Controller
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('success', trans('admin::app.response.delete-failed', ['name' => 'Review']));
}

View File

@ -523,7 +523,7 @@ class Bundle extends AbstractType
*/
public function getAdditionalOptions($data)
{
$bundleOptionQuantities = $data['bundle_option_qty'];
$bundleOptionQuantities = $data['bundle_option_qty'] ?? [];
foreach ($data['bundle_options'] as $optionId => $optionProductIds) {
$option = $this->productBundleOptionRepository->find($optionId);

View File

@ -12,6 +12,8 @@ class AddStoredFunctionToGetUrlPathOfCategory extends Migration
*/
public function up()
{
$dbPrefix = DB::getTablePrefix();
$functionSQL = <<< SQL
DROP FUNCTION IF EXISTS `get_url_path_of_category`;
CREATE FUNCTION get_url_path_of_category(
@ -21,7 +23,7 @@ class AddStoredFunctionToGetUrlPathOfCategory extends Migration
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE urlPath VARCHAR(255);
-- Category with id 1 is root by default
IF categoryId <> 1
@ -29,9 +31,9 @@ class AddStoredFunctionToGetUrlPathOfCategory extends Migration
SELECT
GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO urlPath
FROM
categories AS node,
categories AS parent
JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id
${dbPrefix}categories AS node,
${dbPrefix}categories AS parent
JOIN ${dbPrefix}category_translations AS parent_translations ON parent.id = parent_translations.category_id
WHERE
node._lft >= parent._lft
AND node._rgt <= parent._rgt
@ -40,15 +42,15 @@ class AddStoredFunctionToGetUrlPathOfCategory extends Migration
AND parent_translations.locale = localeCode
GROUP BY
node.id;
IF urlPath IS NULL
THEN
SET urlPath = (SELECT slug FROM category_translations WHERE category_translations.category_id = categoryId);
SET urlPath = (SELECT slug FROM ${dbPrefix}category_translations WHERE ${dbPrefix}category_translations.category_id = categoryId);
END IF;
ELSE
SET urlPath = '';
END IF;
RETURN urlPath;
END;
SQL;

View File

@ -2,6 +2,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Migrations\Migration;
use Webkul\Category\Models\CategoryTranslation;
class AddTriggerToCategoryTranslations extends Migration
{
@ -15,11 +16,13 @@ class AddTriggerToCategoryTranslations extends Migration
*/
public function up()
{
$dbPrefix = DB::getTablePrefix();
$triggerBody = $this->getTriggerBody();
$insertTrigger = <<< SQL
CREATE TRIGGER %s
BEFORE INSERT ON category_translations
FOR EACH ROW
BEFORE INSERT ON ${dbPrefix}category_translations
FOR EACH ROW
BEGIN
$triggerBody
END;
@ -27,8 +30,8 @@ SQL;
$updateTrigger = <<< SQL
CREATE TRIGGER %s
BEFORE UPDATE ON category_translations
FOR EACH ROW
BEFORE UPDATE ON ${dbPrefix}category_translations
FOR EACH ROW
BEGIN
$triggerBody
END;
@ -59,20 +62,22 @@ SQL;
*/
private function getTriggerBody()
{
$dbPrefix = DB::getTablePrefix();
return <<<SQL
DECLARE parentUrlPath varchar(255);
DECLARE urlPath varchar(255);
-- Category with id 1 is root by default
IF NEW.category_id <> 1
THEN
SELECT
GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO parentUrlPath
FROM
categories AS node,
categories AS parent
JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id
${dbPrefix}categories AS node,
${dbPrefix}categories AS parent
JOIN ${dbPrefix}category_translations AS parent_translations ON parent.id = parent_translations.category_id
WHERE
node._lft >= parent._lft
AND node._rgt <= parent._rgt
@ -81,16 +86,16 @@ SQL;
AND parent_translations.locale = NEW.locale
GROUP BY
node.id;
IF parentUrlPath IS NULL
IF parentUrlPath IS NULL
THEN
SET urlPath = NEW.slug;
ELSE
SET urlPath = concat(parentUrlPath, '/', NEW.slug);
END IF;
SET NEW.url_path = urlPath;
END IF;
SQL;

View File

@ -16,10 +16,11 @@ class AddTriggerToCategories extends Migration
public function up()
{
$triggerBody = $this->getTriggerBody();
$dbPrefix = DB::getTablePrefix();
$insertTrigger = <<< SQL
CREATE TRIGGER %s
AFTER INSERT ON categories
CREATE TRIGGER %s
AFTER INSERT ON ${dbPrefix}categories
FOR EACH ROW
BEGIN
$triggerBody
@ -27,8 +28,8 @@ class AddTriggerToCategories extends Migration
SQL;
$updateTrigger = <<< SQL
CREATE TRIGGER %s
AFTER UPDATE ON categories
CREATE TRIGGER %s
AFTER UPDATE ON ${dbPrefix}categories
FOR EACH ROW
BEGIN
$triggerBody
@ -60,39 +61,41 @@ SQL;
*/
private function getTriggerBody(): string
{
$dbPrefix = DB::getTablePrefix();
return <<< SQL
DECLARE urlPath VARCHAR(255);
DECLARE localeCode VARCHAR(255);
DECLARE done INT;
DECLARE curs CURSOR FOR (SELECT category_translations.locale
FROM category_translations
DECLARE curs CURSOR FOR (SELECT ${dbPrefix}category_translations.locale
FROM ${dbPrefix}category_translations
WHERE category_id = NEW.id);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
IF EXISTS (
SELECT *
FROM category_translations
FROM ${dbPrefix}category_translations
WHERE category_id = NEW.id
)
THEN
OPEN curs;
SET done = 0;
REPEAT
REPEAT
FETCH curs INTO localeCode;
SELECT get_url_path_of_category(NEW.id, localeCode) INTO urlPath;
UPDATE category_translations
SET url_path = urlPath
WHERE category_translations.category_id = NEW.id;
UPDATE ${dbPrefix}category_translations
SET url_path = urlPath
WHERE ${dbPrefix}category_translations.category_id = NEW.id;
UNTIL done END REPEAT;
CLOSE curs;
END IF;
SQL;
}

View File

@ -16,10 +16,12 @@ class AlterTriggerCategoryTranslations extends Migration
public function up()
{
$triggerBody = $this->getTriggerBody();
$dbPrefix = DB::getTablePrefix();
$insertTrigger = <<< SQL
CREATE TRIGGER %s
BEFORE INSERT ON category_translations
FOR EACH ROW
BEFORE INSERT ON ${dbPrefix}category_translations
FOR EACH ROW
BEGIN
$triggerBody
END;
@ -27,8 +29,8 @@ SQL;
$updateTrigger = <<< SQL
CREATE TRIGGER %s
BEFORE UPDATE ON category_translations
FOR EACH ROW
BEFORE UPDATE ON ${dbPrefix}category_translations
FOR EACH ROW
BEGIN
$triggerBody
END;
@ -66,44 +68,46 @@ SQL;
*/
private function getTriggerBody()
{
$dbPrefix = DB::getTablePrefix();
return <<<SQL
DECLARE parentUrlPath varchar(255);
DECLARE urlPath varchar(255);
IF NOT EXISTS (
SELECT id
FROM categories
FROM ${dbPrefix}categories
WHERE
id = NEW.category_id
AND parent_id IS NULL
)
THEN
SELECT
GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO parentUrlPath
FROM
categories AS node,
categories AS parent
JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id
${dbPrefix}categories AS node,
${dbPrefix}categories AS parent
JOIN ${dbPrefix}category_translations AS parent_translations ON parent.id = parent_translations.category_id
WHERE
node._lft >= parent._lft
AND node._rgt <= parent._rgt
AND node.id = (SELECT parent_id FROM categories WHERE id = NEW.category_id)
AND node.parent_id IS NOT NULL
AND node.id = (SELECT parent_id FROM ${dbPrefix}categories WHERE id = NEW.category_id)
AND node.parent_id IS NOT NULL
AND parent.parent_id IS NOT NULL
AND parent_translations.locale = NEW.locale
GROUP BY
node.id;
IF parentUrlPath IS NULL
IF parentUrlPath IS NULL
THEN
SET urlPath = NEW.slug;
ELSE
SET urlPath = concat(parentUrlPath, '/', NEW.slug);
END IF;
SET NEW.url_path = urlPath;
END IF;
SQL;

View File

@ -12,6 +12,8 @@ class AlterStoredFunctionUrlPathCategory extends Migration
*/
public function up()
{
$dbPrefix = DB::getTablePrefix();
$functionSQL = <<< SQL
DROP FUNCTION IF EXISTS `get_url_path_of_category`;
CREATE FUNCTION get_url_path_of_category(
@ -21,12 +23,12 @@ class AlterStoredFunctionUrlPathCategory extends Migration
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE urlPath VARCHAR(255);
IF NOT EXISTS (
SELECT id
FROM categories
SELECT id
FROM ${dbPrefix}categories
WHERE
id = categoryId
AND parent_id IS NULL
@ -35,9 +37,9 @@ class AlterStoredFunctionUrlPathCategory extends Migration
SELECT
GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO urlPath
FROM
categories AS node,
categories AS parent
JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id
${dbPrefix}categories AS node,
${dbPrefix}categories AS parent
JOIN ${dbPrefix}category_translations AS parent_translations ON parent.id = parent_translations.category_id
WHERE
node._lft >= parent._lft
AND node._rgt <= parent._rgt
@ -47,15 +49,15 @@ class AlterStoredFunctionUrlPathCategory extends Migration
AND parent_translations.locale = localeCode
GROUP BY
node.id;
IF urlPath IS NULL
THEN
SET urlPath = (SELECT slug FROM category_translations WHERE category_translations.category_id = categoryId);
SET urlPath = (SELECT slug FROM ${dbPrefix}category_translations WHERE ${dbPrefix}category_translations.category_id = categoryId);
END IF;
ELSE
SET urlPath = '';
END IF;
RETURN urlPath;
END;
SQL;

View File

@ -18,10 +18,11 @@ class AlterTriggerOnCategories extends Migration
public function up()
{
$triggerBody = $this->getTriggerBody();
$dbPrefix = DB::getTablePrefix();
$insertTrigger = <<< SQL
CREATE TRIGGER %s
AFTER INSERT ON categories
CREATE TRIGGER %s
AFTER INSERT ON ${dbPrefix}categories
FOR EACH ROW
BEGIN
$triggerBody
@ -29,8 +30,8 @@ class AlterTriggerOnCategories extends Migration
SQL;
$updateTrigger = <<< SQL
CREATE TRIGGER %s
AFTER UPDATE ON categories
CREATE TRIGGER %s
AFTER UPDATE ON ${dbPrefix}categories
FOR EACH ROW
BEGIN
$triggerBody
@ -68,46 +69,48 @@ SQL;
*/
private function getTriggerBody(): string
{
$dbPrefix = DB::getTablePrefix();
return <<< SQL
DECLARE urlPath VARCHAR(255);
DECLARE localeCode VARCHAR(255);
DECLARE done INT;
DECLARE curs CURSOR FOR (SELECT category_translations.locale
FROM category_translations
DECLARE curs CURSOR FOR (SELECT ${dbPrefix}category_translations.locale
FROM ${dbPrefix}category_translations
WHERE category_id = NEW.id);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
IF EXISTS (
SELECT *
FROM category_translations
FROM ${dbPrefix}category_translations
WHERE category_id = NEW.id
)
THEN
OPEN curs;
SET done = 0;
REPEAT
REPEAT
FETCH curs INTO localeCode;
SELECT get_url_path_of_category(NEW.id, localeCode) INTO urlPath;
IF NEW.parent_id IS NULL
IF NEW.parent_id IS NULL
THEN
SET urlPath = '';
END IF;
UPDATE category_translations
SET url_path = urlPath
WHERE
category_translations.category_id = NEW.id
AND category_translations.locale = localeCode;
UPDATE ${dbPrefix}category_translations
SET url_path = urlPath
WHERE
${dbPrefix}category_translations.category_id = NEW.id
AND ${dbPrefix}category_translations.locale = localeCode;
UNTIL done END REPEAT;
CLOSE curs;
END IF;
SQL;
}

View File

@ -182,6 +182,8 @@ class CartController extends Controller
'message' => trans('shop::app.checkout.total.invalid-coupon')
]);
} catch (\Exception $e) {
report($e);
return response()->json([
'success' => false,
'message' => trans('shop::app.checkout.total.coupon-apply-issue')

View File

@ -75,6 +75,7 @@ class SubscriptionController extends Controller
session()->flash('success', trans('shop::app.subscription.subscribed'));
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('shop::app.subscription.not-subscribed'));
$mailSent = false;

View File

@ -282,6 +282,7 @@ class TaxRateController extends Controller
}
}
} catch (\Exception $e) {
report($e);
$failure = new Failure(1, 'rows', [0 => trans('admin::app.export.enough-row-error')]);
session()->flash('error', $failure->errors()[0]);

View File

@ -2,6 +2,7 @@
namespace Webkul\User\Database\Seeders;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use DB;
@ -16,6 +17,9 @@ class AdminsTableSeeder extends Seeder
'name' => 'Example',
'email' => 'admin@example.com',
'password' => bcrypt('admin123'),
'api_token' => Str::random(80),
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
'status' => 1,
'role_id' => 1,
]);

View File

@ -2,6 +2,7 @@
namespace Webkul\User\Http\Controllers;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Event;
use Webkul\User\Repositories\AdminRepository;
use Webkul\User\Repositories\RoleRepository;
@ -90,8 +91,10 @@ class UserController extends Controller
{
$data = $request->all();
if (isset($data['password']) && $data['password'])
if (isset($data['password']) && $data['password']) {
$data['password'] = bcrypt($data['password']);
$data['api_token'] = Str::random(80);
}
Event::dispatch('user.admin.create.before');
@ -130,10 +133,11 @@ class UserController extends Controller
{
$data = $request->all();
if (! $data['password'])
if (! $data['password']) {
unset($data['password']);
else
} else {
$data['password'] = bcrypt($data['password']);
}
if (isset($data['status'])) {
$data['status'] = 1;

View File

@ -19,7 +19,7 @@ class Admin extends Authenticatable implements AdminContract
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'role_id', 'status',
'name', 'email', 'password', 'api_token', 'role_id', 'status',
];
/**
@ -28,7 +28,7 @@ class Admin extends Authenticatable implements AdminContract
* @var array
*/
protected $hidden = [
'password', 'remember_token',
'password', 'api_token', 'remember_token',
];
/**