File "UpdateProfilePicture.php"

Full Path: /home/fundopuh/trader.fxex.org/app/Http/Livewire/User/AccountSettings/UpdateProfilePicture.php
File size: 1.19 KB
MIME-type: text/x-php
Charset: utf-8

<?php  
// this Code is Cracked by dharunMods-YouTube-Channel

namespace App\Http\Livewire\User\AccountSettings;

use App\Models\Settings;
use App\Models\User;
use Illuminate\Support\Facades\Log;
use Livewire\Component;
use Livewire\WithFileUploads;

class UpdateProfilePicture extends Component
{
    public $photo;
    public $photoPath;

    use WithFileUploads;

    public function mount()
    {
        $this->photoPath = auth()->user()->profile_photo_path;
    }
    public function render()
    {
        $settings = Settings::select('theme')->find(1);
        return view("{$settings->theme}.livewire.user.account-settings.update-profile-picture");
    }

    public function update()
    {
        Log::info("Your profile picture");
        $this->validate([
            'photo' => ['required', 'image', 'max:1024', 'mimes:jpg,jpeg,png'],
        ]);

        $user = User::find(auth()->user()->id);
        $user->profile_photo_path = $this->photo->store('profile-photos', 'public');
        $user->save();

        $this->photoPath = $user->profile_photo_path;
        $this->dispatchBrowserEvent('profile-updated', ['message' => 'Your profile picture is updated successfully.', 'type' => 'success']);
    }
}