HEX
Server: LiteSpeed
System: Linux sv4.hami.host 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: armgroup (1008)
PHP: 8.2.32
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, mail, socket_create, socket_create_listen, socket_create_pair, link, dl, openlog, syslog, stream_socket_server, curl_multi_init
Upload Files
File: /home/armgroup/libs/app/Http/Livewire/Auth/Normal.php
<?php

namespace App\Http\Livewire\Auth;

use App\Http\Livewire\ConvertEmptyStringsToNull;
use App\Http\Livewire\General;
use App\Models\NewsletterMember;
use App\Models\User;
use App\Models\Verification;
use Gloudemans\Shoppingcart\Facades\Cart;
use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Livewire\Component;

class Normal extends Component
{
    use ConvertEmptyStringsToNull, General, MobileVerification;

    public $name;

    public $email;

    public $password;

    public $password_confirmation;

    public $newsletter = 1;

    public $terms = 1;

    public function render()
    {
        return view('livewire.auth.normal');
    }

    protected function rules()
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['nullable', 'string', 'max:255', 'email', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
            'newsletter' => ['required', 'boolean'],
            'terms' => ['required', 'accepted'],
        ];
    }

    public function save()
    {
        $this->validate();

        $mobile = session('verification')['mobile'];

        $code = session('verification')['code'];

        if ($this->canTakeMobile($mobile, $code)) {
            DB::transaction(function () use ($mobile) {
                Verification::whereMobile($mobile)->delete();

                $user = User::create([
                    'name' => $this->name,
                    'email' => $this->email,
                    'mobile' => $mobile,
                    'password' => Hash::make($this->password),
                ]);

                if ($this->newsletter) {
                    NewsletterMember::updateOrCreate(['mobile' => $mobile]);
                }

                event(new Registered($user));

                Auth::guard()->login($user);
            });

            session()->forget('verification');
            
            // $this->dispatchBrowserEvent('showSwal', [
            //     'title' => 'تکمیل ثبت‌نام',
            //     'html'  => '<p>ثبت‌نام با موفقیت انجام شد</p>
            //                 <label>
            //                     <input type="checkbox" id="go_complete"> می‌خواهم اطلاعاتم را تکمیل کنم
            //                 </label>',
            //     'confirmUrlChecked'   => 'https://store.armgroupco.com/register/seller',        
            //     'confirmUrlUnchecked' => 'https://store.armgroupco.com', 
            //     'cancelUrl'           => '/route-if-cancel',                    
            // ]);
            
            
            
            
            $this->dispatchBrowserEvent('showSwal', [
                'title' => 'تکمیل ثبت‌نام',
                'html'  => '<p>ثبت‌نام با موفقیت انجام شد</p>
                            <label>
                                <input type="checkbox" id="go_complete"> می‌خواهم اطلاعاتم را تکمیل کنم
                            </label>',
                'confirmUrlChecked'   => route('register.seller'),        
                'confirmUrlChecked'   => route('account.seller-information.edit'),        
                'confirmUrlUnchecked' => Cart::count() ? route('checkout.index') : route('account.index'), 
                'cancelUrl'           => route('account.index'),                    
            ]);
     
            // if (Cart::count()) {
            //     return redirect()->route('checkout.index');
            // }
        
            // return redirect()->route('account.index');
        } else {
            $this->doneMessage('Error', 'error');

            return redirect()->route('register');
        }
    }
}