Actualizacuion de Rama Kquiroz

This commit is contained in:
ellecio2
2023-09-04 19:53:37 -04:00
parent d2e9ba53ab
commit 2e99d7b290
2206 changed files with 100145 additions and 467275 deletions

View File

@@ -11,11 +11,14 @@ use App\Models\Order;
use App\Models\OrderDetail;
use Illuminate\Support\Facades\Hash;
use App\Notifications\EmailVerificationNotification;
use App\Notifications\ShopVerificationNotification;
use Cache;
use Illuminate\Support\Facades\Notification;
class SellerController extends Controller
{
public function __construct() {
public function __construct()
{
// Staff Permission Check
$this->middleware(['permission:view_all_seller'])->only('index');
$this->middleware(['permission:view_seller_profile'])->only('profile_modal');
@@ -36,9 +39,9 @@ class SellerController extends Controller
$sort_search = null;
$approved = null;
$shops = Shop::whereIn('user_id', function ($query) {
$query->select('id')
->from(with(new User)->getTable());
})->latest();
$query->select('id')
->from(with(new User)->getTable());
})->latest();
if ($request->has('search')) {
$sort_search = $request->search;
@@ -209,13 +212,14 @@ class SellerController extends Controller
{
$shop = Shop::findOrFail($id);
$shop->verification_status = 1;
if ($shop->save()) {
Cache::forget('verified_sellers_id');
flash(translate('Seller has been approved successfully'))->success();
return redirect()->route('sellers.index');
}
flash(translate('Something went wrong'))->error();
return back();
$shop->save();
Cache::forget('verified_sellers_id');
$users = User::findMany([$shop->user->id, User::where('user_type', 'admin')->first()->id]);
Notification::send($users, new ShopVerificationNotification($shop, 'approved'));
flash(translate('Seller has been approved successfully'))->success();
return redirect()->route('sellers.index');
}
public function reject_seller($id)
@@ -223,13 +227,14 @@ class SellerController extends Controller
$shop = Shop::findOrFail($id);
$shop->verification_status = 0;
$shop->verification_info = null;
if ($shop->save()) {
Cache::forget('verified_sellers_id');
flash(translate('Seller verification request has been rejected successfully'))->success();
return redirect()->route('sellers.index');
}
flash(translate('Something went wrong'))->error();
return back();
$shop->save();
Cache::forget('verified_sellers_id');
$users = User::findMany([$shop->user->id, User::where('user_type', 'admin')->first()->id]);
Notification::send($users, new ShopVerificationNotification($shop, 'rejected'));
flash(translate('Seller verification request has been rejected successfully'))->success();
return redirect()->route('sellers.index');
}
@@ -249,11 +254,13 @@ class SellerController extends Controller
{
$shop = Shop::findOrFail($request->id);
$shop->verification_status = $request->status;
if ($shop->save()) {
Cache::forget('verified_sellers_id');
return 1;
}
return 0;
$shop->save();
Cache::forget('verified_sellers_id');
$status = $request->status == 1 ? 'approved' : 'rejected';
$users = User::findMany([$shop->user->id, User::where('user_type', 'admin')->first()->id]);
Notification::send($users, new ShopVerificationNotification($shop, $status));
return 1;
}
public function login($id)