Path : /var/www/html/phkaynews-v2/app/Http/Livewire/Admin/ |
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
Current File : /var/www/html/phkaynews-v2/app/Http/Livewire/Admin/UserManage.php |
<?php namespace App\Http\Livewire\Admin; use App\Models\User; use Jantinnerezo\LivewireAlert\LivewireAlert; use Livewire\Component; use Livewire\WithPagination; class UserManage extends Component { use LivewireAlert; use WithPagination; protected $paginationTheme = 'bootstrap'; public $item,$total_item; public $s, $per_page, $readyLoadingItem = false; public $sortBy = 'created_at'; public $sortDirection = 'desc'; public $limited = 10, $show_limit = [10, 25, 50, 100]; protected $listeners =[ 'confirmed', 'addItem', 'updatedItem', ]; public function getUsersProperty() { return User::when($this->s, function ($query) { return $query->where('name', 'like', '%' . $this->s . '%'); })->orderBy($this->sortBy,$this->sortDirection)->paginate($this->limited); } public function render() { $this->total_item = User::count(); return view('livewire.admin.user-manage',[ 'users' => $this->readyLoadingItem ? $this->users : [] ])->layout('layouts.admin'); } public function loadingItem() { $this->readyLoadingItem = true; } public function sortBy($field) { $this->sortDirection = $this->sortBy === $field ? $this->reverseSort() : 'asc'; $this->sortBy = $field; } public function reverseSort() { return $this->sortDirection === 'asc' ? 'desc' : 'asc'; } public function addItem($data) { $this->advertise = $data; $this->alert('success', 'Your item has been create successfully.', [ 'position' => 'top', 'toast' => true, 'showCancelButton' => false, 'showConfirmButton' => false, 'timerProgressBar' => true, ]); } public function updatedItem() { $this->alert('success', 'Your item has been update successfully.', [ 'position' => 'top', 'toast' => true, 'showCancelButton' => false, 'showConfirmButton' => false, 'timerProgressBar' => true, ]); } public function confirmed() { $this->item->delete(); $old_img = public_path($this->item->feature_image); //is get path old image if (file_exists($old_img)) { unlink($old_img); } $action = 'delete'; $this->alert('success', 'Your item has been ' . $action . ' successfully.', [ 'position' => 'top', 'toast' => true, 'showCancelButton' => false, 'showConfirmButton' => false, 'timerProgressBar' => true, ]); } public function destroy(User $user) { $this->item = $user; $this->confirm("You won't be able to revert this!", [ 'toast' => false, 'position' => 'center', 'showConfirmButton' => true, 'onConfirmed' => 'confirmed', 'onCancelled' => 'cancelled', 'confirmButtonText' => 'Yes, move trash!', 'showCancelButton' => !0, 'cancelButtonText' => "No, cancel!", 'customClass' => [ 'confirmButton' => 'btn btn-success mt-2', 'cancelButton' => 'btn btn-danger ml-2 mt-2' ], 'buttonsStyling' => false, ]); } }