Fixed livewire script loading issues
This commit is contained in:
parent
b2b8bca9ea
commit
e3b6d302c6
11 changed files with 37 additions and 28 deletions
|
|
@ -6,10 +6,7 @@ use App\Livewire\Forms\RegisterUserForm;
|
||||||
use App\Mail\PasswordResetNewUser;
|
use App\Mail\PasswordResetNewUser;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\UserProfile;
|
use App\Models\UserProfile;
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Log\Logger;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\View\View;
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class RegisterUser extends Component
|
class RegisterUser extends Component
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace App\Livewire;
|
||||||
|
|
||||||
use App\Livewire\Forms\MovieListForm;
|
use App\Livewire\Forms\MovieListForm;
|
||||||
use App\Models\MovieList;
|
use App\Models\MovieList;
|
||||||
|
use Exception;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class MovieLists extends Component
|
class MovieLists extends Component
|
||||||
|
|
@ -20,7 +21,12 @@ class MovieLists extends Component
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$validated = $this->form->validate();
|
$validated = $this->form->validate();
|
||||||
MovieList::create(array_merge($validated, ["user_id" => $user->id]));
|
|
||||||
|
try {
|
||||||
|
MovieList::create(array_merge($validated, ["user_id" => $user->id]));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->addError("new-list", "Could not create movie list");
|
||||||
|
}
|
||||||
|
|
||||||
$this->getLists();
|
$this->getLists();
|
||||||
$this->form->reset();
|
$this->form->reset();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
<x-header/>
|
<x-header/>
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</div>
|
</div>
|
||||||
@livewireScriptConfig
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
@props(['wire:model'])
|
@props(['wire:model.live'])
|
||||||
|
|
||||||
<div x-data="{ open: @entangle($attributes->wire('model')) }" x-show="open" @keydown.escape.window="open = false">
|
<div x-data="{ open: @entangle($attributes->wire('model')).live }" x-show="open" @keydown.escape.window="open = false">
|
||||||
<!-- Overlay -->
|
<!-- Overlay -->
|
||||||
<div x-show="open"
|
<div x-show="open"
|
||||||
x-transition:enter="transition-opacity ease-linear duration-300"
|
x-transition:enter="transition-opacity ease-linear duration-300"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
@props(['model'])
|
@props(['model'])
|
||||||
|
|
||||||
<div x-data="{ open: @entangle($model) }" @keydown.escape.window="open = false">
|
<div x-data="{ open: @entangle($model).live }" @keydown.escape.window="open = false">
|
||||||
<!-- Overlay -->
|
<!-- Overlay -->
|
||||||
<div x-show="open"
|
<div x-show="open"
|
||||||
x-transition:enter="transition-opacity ease-linear duration-300"
|
x-transition:enter="transition-opacity ease-linear duration-300"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<input name="list_name" placeholder="List Name"
|
<input name="list_name" placeholder="List Name"
|
||||||
class="flex-1 w-full text-black bg-white p-2 rounded rounded-r-none"
|
class="flex-1 w-full text-black bg-white p-2 rounded rounded-r-none"
|
||||||
type="text"
|
type="text"
|
||||||
wire:model="form.name">
|
wire:model.live="form.name">
|
||||||
<button type="submit" class="bg-green-400 text-white px-4 py-2 rounded rounded-l-none">Add</button>
|
<button type="submit" class="bg-green-400 text-white px-4 py-2 rounded rounded-l-none">Add</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -33,4 +33,3 @@
|
||||||
</ul>
|
</ul>
|
||||||
</x-ui.card>
|
</x-ui.card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,27 @@
|
||||||
<div class="w-full flex-shrink-0 flex flex-col gap-5">
|
<div class="w-full flex-shrink-0 flex flex-col gap-5">
|
||||||
<div class="flex flex-col-reverse sm:flex-row gap-5 sm:gap-0 justify-between w-full">
|
<div class="flex flex-col-reverse sm:flex-row gap-5 sm:gap-0 justify-between w-full">
|
||||||
<input class="flex bg-white p-2 rounded sm:w-100" type="text" placeholder="Filter movies"
|
<input class="flex bg-white p-2 rounded sm:w-100" type="text" placeholder="Filter movies"
|
||||||
wire:model="filterText"
|
wire:model.live="filterText"
|
||||||
wire:keyup="filterMovies"/>
|
wire:keyup="filterMovies"/>
|
||||||
|
|
||||||
<button wire:click="$dispatch('openSearch')" class="bg-green-500 text-white p-2 rounded">
|
<button wire:click="$dispatch('openSearch')" class="bg-green-500 text-white p-2 rounded">
|
||||||
Add Movie
|
Add Movie
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<ul class="grid grid-cols-2 sm:grid-cols-4 gap-5">
|
@if(!empty($filteredMovies))
|
||||||
@foreach ($filteredMovies as $movie)
|
<ul class="grid grid-cols-2 sm:grid-cols-4 gap-5">
|
||||||
<li class="bg-gray-200">
|
@foreach ($filteredMovies as $movie)
|
||||||
<x-movie :movie="$movie"/>
|
<li class="bg-gray-200">
|
||||||
</li>
|
<x-movie :movie="$movie"/>
|
||||||
@endforeach
|
</li>
|
||||||
</ul>
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@else
|
||||||
|
<div class="flex flex-col items-center justify-center my-10">
|
||||||
|
<span class="text-center p-5 font-bold text-2xl">"You complete me."</span>
|
||||||
|
<span class="text-center">Tom Cruise, <i>Jerry Maguire</i></span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Settings View -->
|
<!-- Settings View -->
|
||||||
|
|
@ -49,7 +56,7 @@
|
||||||
<div class="flex flex-col gap-2 w-full">
|
<div class="flex flex-col gap-2 w-full">
|
||||||
<label for="list-name">List Name</label>
|
<label for="list-name">List Name</label>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<input type="text" wire:model="settingsForm.name" id="list-name"
|
<input type="text" wire:model.live="settingsForm.name" id="list-name"
|
||||||
class="w-full p-2 rounded rounded-r-none bg-white"/>
|
class="w-full p-2 rounded rounded-r-none bg-white"/>
|
||||||
<button class="bg-green-400 p-2 rounded-r" type="submit" wire:click="saveSettings">Save
|
<button class="bg-green-400 p-2 rounded-r" type="submit" wire:click="saveSettings">Save
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<x-ui.slide-over model="showSearch">
|
<x-ui.slide-over model="showSearch">
|
||||||
<form wire:submit.prevent="findMovies" class="flex flex-row">
|
<form wire:submit="findMovies" class="flex flex-row">
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<label for="query">Enter a movie title</label>
|
<label for="query">Enter a movie title</label>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<input wire:model="query" type="text" name="query" class="bg-white p-2 text-black"/>
|
<input wire:model.live="query" type="text" name="query" class="bg-white p-2 text-black"/>
|
||||||
<button class="bg-green-400 p-2" type="submit">Search</button>
|
<button class="bg-green-400 p-2" type="submit">Search</button>
|
||||||
</div>
|
</div>
|
||||||
@error('query') <span class="error text-red-500">{{ $message }}</span> @enderror
|
@error('query') <span class="error text-red-500">{{ $message }}</span> @enderror
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="text-2xl">
|
<div class="text-2xl">
|
||||||
<h1 class="text-center m-5">Create Account</h1>
|
<h1 class="text-center m-5">Create Account</h1>
|
||||||
|
|
||||||
<form class="flex flex-col gap-5" wire:submit.prevent="register">
|
<form class="flex flex-col gap-5" wire:submit="register">
|
||||||
@if($errors->any())
|
@if($errors->any())
|
||||||
<div class="text-red-500">
|
<div class="text-red-500">
|
||||||
@foreach($errors->all() as $error)
|
@foreach($errors->all() as $error)
|
||||||
|
|
@ -12,11 +12,11 @@
|
||||||
|
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<label class="py-5" for="username">Username</label>
|
<label class="py-5" for="username">Username</label>
|
||||||
<input class="bg-white" type="text" wire:model="form.username"/>
|
<input class="bg-white" type="text" wire:model.live="form.username"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<label class="py-5" for="email">Email</label>
|
<label class="py-5" for="email">Email</label>
|
||||||
<input class="bg-white" type="email" wire:model="form.email"/>
|
<input class="bg-white" type="email" wire:model.live="form.email"/>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="bg-green-400 text-white px-4 py-2 rounded">Submit</button>
|
<button type="submit" class="bg-green-400 text-white px-4 py-2 rounded">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="text-2xl">
|
<div class="text-2xl">
|
||||||
<h1 class="text-center m-5">Reset Password</h1>
|
<h1 class="text-center m-5">Reset Password</h1>
|
||||||
|
|
||||||
<form class="flex flex-col gap-5" wire:submit.prevent="resetPassword">
|
<form class="flex flex-col gap-5" wire:submit="resetPassword">
|
||||||
@csrf
|
@csrf
|
||||||
@if($errors->any())
|
@if($errors->any())
|
||||||
<div class="text-red-500">
|
<div class="text-red-500">
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
class="bg-white"
|
class="bg-white"
|
||||||
type="email"
|
type="email"
|
||||||
name="email"
|
name="email"
|
||||||
wire:model="form.email"
|
wire:model.live="form.email"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
class="bg-white"
|
class="bg-white"
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
wire:model="form.password"
|
wire:model.live="form.password"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
class="bg-white"
|
class="bg-white"
|
||||||
type="password"
|
type="password"
|
||||||
name="password_confirmation"
|
name="password_confirmation"
|
||||||
wire:model="form.password_confirmation"
|
wire:model.live="form.password_confirmation"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Submit</button>
|
<button type="submit">Submit</button>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ Route::view('/login', 'pages.auth.login')->name('login');
|
||||||
|
|
||||||
/* AUTH */
|
/* AUTH */
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
|
Route::get('/', fn() => redirect()->route('lists'));
|
||||||
Route::get('/lists', MovieLists::class)->name('lists');
|
Route::get('/lists', MovieLists::class)->name('lists');
|
||||||
Route::get('/lists/{id}', MovieList::class)->name('list');
|
Route::get('/lists/{id}', MovieList::class)->name('list');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue