-
app/Http/Livewire/Profile.php
Open in GitHubuse App\Models\User; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Livewire\Component; class Profile extends Component { public User $user; public $showSavedAlert = false; public $showDemoNotification = false; public function rules() { return [ 'user.first_name' => 'max:15', 'user.last_name' => 'max:20', 'user.email' => 'email', 'user.gender' => ['required', Rule::in(['Male', 'Female', 'Other'])], 'user.address' => 'max:40', 'user.number' => 'numeric', 'user.city' => 'max:20', 'user.ZIP' => 'numeric', ]; } public function mount() { $this->user = auth()->user(); } public function save() { if(env('IS_DEMO')) { $this->showDemoNotification = true; } else { $this->validate(); $this->user->save(); $this->showSavedAlert = true; } } public function render() { return view('livewire.profile'); } }
-
resources/views/livewire/profile.blade.php
Open in GitHub<div> <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center py-4"> <div> <button class="btn btn-secondary me-2 dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="fas fa-plus me-2"></span>New </button> <div class="dropdown-menu dashboard-dropdown dropdown-menu-start mt-2 py-1"> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-400 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z" clip-rule="evenodd"></path> </svg> Document </a> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-400 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z" clip-rule="evenodd"></path> </svg> Message </a> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-400 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path d="M5.5 13a3.5 3.5 0 01-.369-6.98 4 4 0 117.753-1.977A4.5 4.5 0 1113.5 13H11V9.413l1.293 1.293a1 1 0 001.414-1.414l-3-3a1 1 0 00-1.414 0l-3 3a1 1 0 001.414 1.414L9 9.414V13H5.5z"> </path> <path d="M9 13h2v5a1 1 0 11-2 0v-5z"></path> </svg> Product </a> <div role="separator" class="dropdown-divider my-1"></div> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-danger me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M12.395 2.553a1 1 0 00-1.45-.385c-.345.23-.614.558-.822.88-.214.33-.403.713-.57 1.116-.334.804-.614 1.768-.84 2.734a31.365 31.365 0 00-.613 3.58 2.64 2.64 0 01-.945-1.067c-.328-.68-.398-1.534-.398-2.654A1 1 0 005.05 6.05 6.981 6.981 0 003 11a7 7 0 1011.95-4.95c-.592-.591-.98-.985-1.348-1.467-.363-.476-.724-1.063-1.207-2.03zM12.12 15.12A3 3 0 017 13s.879.5 2.5.5c0-1 .5-4 1.25-4.5.5 1 .786 1.293 1.371 1.879A2.99 2.99 0 0113 13a2.99 2.99 0 01-.879 2.121z" clip-rule="evenodd"></path> </svg> My Plan </a> </div> </div> <div> <button type="button" class="btn btn-gray-800 d-inline-flex align-items-center me-2"> <svg class="icon icon-xs" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"></path> </svg> </button> <button class="btn btn-gray-800 d-inline-flex align-items-center dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <svg class="icon icon-xs me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path d="M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"></path> <path fill-rule="evenodd" d="M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm3 4a1 1 0 000 2h.01a1 1 0 100-2H7zm3 0a1 1 0 000 2h3a1 1 0 100-2h-3zm-3 4a1 1 0 100 2h.01a1 1 0 100-2H7zm3 0a1 1 0 100 2h3a1 1 0 100-2h-3z" clip-rule="evenodd"></path> </svg> Reports <svg class="icon icon-xs ms-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path> </svg> </button> <div class="dropdown-menu dashboard-dropdown dropdown-menu-start mt-2 py-1"> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-400 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path d="M4 3a2 2 0 100 4h12a2 2 0 100-4H4z"></path> <path fill-rule="evenodd" d="M3 8h14v7a2 2 0 01-2 2H5a2 2 0 01-2-2V8zm5 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z" clip-rule="evenodd"></path> </svg> Products </a> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-400 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path d="M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z"> </path> </svg> Customers </a> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-400 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M10 2a4 4 0 00-4 4v1H5a1 1 0 00-.994.89l-1 9A1 1 0 004 18h12a1 1 0 00.994-1.11l-1-9A1 1 0 0015 7h-1V6a4 4 0 00-4-4zm2 5V6a2 2 0 10-4 0v1h4zm-6 3a1 1 0 112 0 1 1 0 01-2 0zm7-1a1 1 0 100 2 1 1 0 000-2z" clip-rule="evenodd"></path> </svg> Orders </a> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-400 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" d="M3 3a1 1 0 000 2v8a2 2 0 002 2h2.586l-1.293 1.293a1 1 0 101.414 1.414L10 15.414l2.293 2.293a1 1 0 001.414-1.414L12.414 15H15a2 2 0 002-2V5a1 1 0 100-2H3zm11 4a1 1 0 10-2 0v4a1 1 0 102 0V7zm-3 1a1 1 0 10-2 0v3a1 1 0 102 0V8zM8 9a1 1 0 00-2 0v2a1 1 0 102 0V9z" clip-rule="evenodd"></path> </svg> Console </a> <div role="separator" class="dropdown-divider my-1"></div> <a class="dropdown-item d-flex align-items-center" href="#"> <svg class="dropdown-icon text-gray-800 me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path d="M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"></path> <path fill-rule="evenodd" d="M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm3 4a1 1 0 000 2h.01a1 1 0 100-2H7zm3 0a1 1 0 000 2h3a1 1 0 100-2h-3zm-3 4a1 1 0 100 2h.01a1 1 0 100-2H7zm3 0a1 1 0 100 2h3a1 1 0 100-2h-3z" clip-rule="evenodd"></path> </svg> All Reports </a> </div> </div> </div> <div class="row"> <div class="col-12 col-xl-8"> @if($showSavedAlert) <div class="alert alert-success" role="alert"> Saved! </div> @endif <div class="card card-body border-0 shadow mb-4"> <h2 class="h5 mb-4">General information</h2> <form wire:submit.prevent="save" action="#" method="POST"> <div class="row"> <div class="col-md-6 mb-3"> <div> <label for="first_name">First Name</label> <input wire:model="user.first_name" class="form-control" id="first_name" type="text" placeholder="Enter your first name" required> </div> </div> <div class="col-md-6 mb-3"> <div> <label for="last_name">Last Name</label> <input wire:model="user.last_name" class="form-control" id="last_name" type="text" placeholder="Also your last name"> </div> </div> </div> <div class="row align-items-center"> <div class="col-md-6 mb-3"> <div class="form-group"> <label for="email">Email</label> <input wire:model="user.email" class="form-control" id="email" type="email" placeholder="name@company.com" disabled> </div> @error('email') <div class="invalid-feedback">{{ $message }}</div> @enderror </div> <div class="col-md-6 mb-3"> <label for="gender">Gender</label> <select wire:model="user.gender" class="form-select mb-0" id="gender" aria-label="Gender select example"> <option selected>Choose...</option> <option value="Female">Female</option> <option value="Male">Male</option> <option value="Other">Other</option> </select> @error('user.gender') <div class="invalid-feedback">{{ $message }}</div> @enderror </div> </div> <h2 class="h5 my-4">Location</h2> <div class="row"> <div class="col-sm-9 mb-3"> <div class="form-group"> <label for="address">Address</label> <input wire:model="user.address" class="form-control" id="address" type="text" placeholder="Enter your home address"> </div> </div> <div class="col-sm-3 mb-3"> <div class="form-group"> <label for="number">Number</label> <input wire:model="user.number" class="form-control" id="number" type="number" placeholder="No."> </div> </div> </div> <div class="row"> <div class="col-sm-4 mb-3"> <div class="form-group"> <label for="city">City</label> <input wire:model="user.city" class="form-control" id="city" type="text" placeholder="City"> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label for="zip">ZIP</label> <input wire:model="user.ZIP" class="form-control" id="zip" type="tel" placeholder="ZIP"> </div> </div> </div> <div class="mt-3"> <button type="submit" class="btn btn-gray-800 mt-2 animate-up-2">Save All</button> </div> </form> @if($showDemoNotification) <div class="alert alert-info mt-2" role="alert"> You cannot do that in the demo version. </div> @endif </div> </div> <div class="col-12 col-xl-4"> <div class="row"> <div class="col-12 mb-4"> <div class="card shadow border-0 text-center p-0"> <div wire:ignore.self class="profile-cover rounded-top" data-background="../assets/img/profile-cover.jpg"></div> <div class="card-body pb-5"> <img src="../assets/img/team/profile-picture-1.jpg" class="avatar-xl rounded-circle mx-auto mt-n7 mb-4" alt="Neil Portrait"> <h4 class="h3"> {{ auth()->user()->first_name ? auth()->user()->first_name . ' ' . auth()->user()->last_name : 'User Name'}} </h4> <h5 class="fw-normal">Senior Software Engineer</h5> <p class="text-gray mb-4">New York, USA</p> <a class="btn btn-sm btn-gray-800 d-inline-flex align-items-center me-2" href="#"> <svg class="icon icon-xs me-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"> <path d="M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"> </path> </svg> Connect </a> <a class="btn btn-sm btn-secondary" href="#">Send Message</a> </div> </div> </div> </div> </div> </div> </div>