-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.x] Adds Livewire's Functional API (#318)
* Adds Livewire Functional API * Apply fixes from StyleCI * Update InstallCommand.php * formatting --------- Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Taylor Otwell <taylor@laravel.com>
- Loading branch information
1 parent
914a8bc
commit d623712
Showing
43 changed files
with
875 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
105 changes: 105 additions & 0 deletions
105
stubs/livewire-functional/resources/views/livewire/layout/navigation.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
$logout = function () { | ||
auth()->guard('web')->logout(); | ||
session()->invalidate(); | ||
session()->regenerateToken(); | ||
$this->redirect('/', navigate: true); | ||
}; | ||
?> | ||
|
||
<nav x-data="{ open: false }" class="bg-white dark:bg-gray-800 border-b border-gray-100 dark:border-gray-700"> | ||
<!-- Primary Navigation Menu --> | ||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | ||
<div class="flex justify-between h-16"> | ||
<div class="flex"> | ||
<!-- Logo --> | ||
<div class="shrink-0 flex items-center"> | ||
<a href="{{ route('dashboard') }}" wire:navigate> | ||
<x-application-logo class="block h-9 w-auto fill-current text-gray-800 dark:text-gray-200" /> | ||
</a> | ||
</div> | ||
|
||
<!-- Navigation Links --> | ||
<div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex"> | ||
<x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')" wire:navigate> | ||
{{ __('Dashboard') }} | ||
</x-nav-link> | ||
</div> | ||
</div> | ||
|
||
<!-- Settings Dropdown --> | ||
<div class="hidden sm:flex sm:items-center sm:ml-6"> | ||
<x-dropdown align="right" width="48"> | ||
<x-slot name="trigger"> | ||
<button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300 focus:outline-none transition ease-in-out duration-150"> | ||
<div x-data="{ name: '{{ auth()->user()->name }}' }" x-text="name" x-on:profile-updated.window="name = $event.detail.name"></div> | ||
|
||
<div class="ml-1"> | ||
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> | ||
<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" /> | ||
</svg> | ||
</div> | ||
</button> | ||
</x-slot> | ||
|
||
<x-slot name="content"> | ||
<x-dropdown-link :href="route('profile')" wire:navigate> | ||
{{ __('Profile') }} | ||
</x-dropdown-link> | ||
|
||
<!-- Authentication --> | ||
<button wire:click="logout" class="w-full text-left"> | ||
<x-dropdown-link> | ||
{{ __('Log Out') }} | ||
</x-dropdown-link> | ||
</button> | ||
</x-slot> | ||
</x-dropdown> | ||
</div> | ||
|
||
<!-- Hamburger --> | ||
<div class="-mr-2 flex items-center sm:hidden"> | ||
<button @click="open = ! open" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-900 focus:outline-none focus:bg-gray-100 dark:focus:bg-gray-900 focus:text-gray-500 dark:focus:text-gray-400 transition duration-150 ease-in-out"> | ||
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24"> | ||
<path :class="{'hidden': open, 'inline-flex': ! open }" class="inline-flex" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" /> | ||
<path :class="{'hidden': ! open, 'inline-flex': open }" class="hidden" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Responsive Navigation Menu --> | ||
<div :class="{'block': open, 'hidden': ! open}" class="hidden sm:hidden"> | ||
<div class="pt-2 pb-3 space-y-1"> | ||
<x-responsive-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')" wire:navigate> | ||
{{ __('Dashboard') }} | ||
</x-responsive-nav-link> | ||
</div> | ||
|
||
<!-- Responsive Settings Options --> | ||
<div class="pt-4 pb-1 border-t border-gray-200 dark:border-gray-600"> | ||
<div class="px-4"> | ||
<div class="font-medium text-base text-gray-800 dark:text-gray-200" x-data="{ name: '{{ auth()->user()->name }}' }" x-text="name" x-on:profile-updated.window="name = $event.detail.name"></div> | ||
<div class="font-medium text-sm text-gray-500">{{ auth()->user()->email }}</div> | ||
</div> | ||
|
||
<div class="mt-3 space-y-1"> | ||
<x-responsive-nav-link :href="route('profile')" wire:navigate> | ||
{{ __('Profile') }} | ||
</x-responsive-nav-link> | ||
|
||
<!-- Authentication --> | ||
<button wire:click="logout" class="w-full text-left"> | ||
<x-responsive-nav-link> | ||
{{ __('Log Out') }} | ||
</x-responsive-nav-link> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> |
64 changes: 64 additions & 0 deletions
64
stubs/livewire-functional/resources/views/livewire/pages/auth/confirm-password.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
use App\Providers\RouteServiceProvider; | ||
use Illuminate\Validation\ValidationException; | ||
use function Livewire\Volt\layout; | ||
use function Livewire\Volt\rules; | ||
use function Livewire\Volt\state; | ||
layout('layouts.guest'); | ||
state(['password' => '']); | ||
rules(['password' => ['required', 'string']]); | ||
$confirmPassword = function () { | ||
$this->validate(); | ||
if (! auth()->guard('web')->validate([ | ||
'email' => auth()->user()->email, | ||
'password' => $this->password, | ||
])) { | ||
throw ValidationException::withMessages([ | ||
'password' => __('auth.password'), | ||
]); | ||
} | ||
session(['auth.password_confirmed_at' => time()]); | ||
$this->redirect( | ||
session('url.intended', RouteServiceProvider::HOME), | ||
navigate: true | ||
); | ||
}; | ||
?> | ||
|
||
<div> | ||
<div class="mb-4 text-sm text-gray-600 dark:text-gray-400"> | ||
{{ __('This is a secure area of the application. Please confirm your password before continuing.') }} | ||
</div> | ||
|
||
<form wire:submit="confirmPassword"> | ||
<!-- Password --> | ||
<div> | ||
<x-input-label for="password" :value="__('Password')" /> | ||
|
||
<x-text-input wire:model="password" | ||
id="password" | ||
class="block mt-1 w-full" | ||
type="password" | ||
name="password" | ||
required autocomplete="current-password" /> | ||
|
||
<x-input-error :messages="$errors->get('password')" class="mt-2" /> | ||
</div> | ||
|
||
<div class="flex justify-end mt-4"> | ||
<x-primary-button> | ||
{{ __('Confirm') }} | ||
</x-primary-button> | ||
</div> | ||
</form> | ||
</div> |
60 changes: 60 additions & 0 deletions
60
stubs/livewire-functional/resources/views/livewire/pages/auth/forgot-password.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
use Illuminate\Support\Facades\Password; | ||
use function Livewire\Volt\layout; | ||
use function Livewire\Volt\rules; | ||
use function Livewire\Volt\state; | ||
layout('layouts.guest'); | ||
state(['email' => '']); | ||
rules(['email' => ['required', 'string', 'email']]); | ||
$sendPasswordResetLink = function () { | ||
$this->validate(); | ||
// We will send the password reset link to this user. Once we have attempted | ||
// to send the link, we will examine the response then see the message we | ||
// need to show to the user. Finally, we'll send out a proper response. | ||
$status = Password::sendResetLink( | ||
$this->only('email') | ||
); | ||
if ($status != Password::RESET_LINK_SENT) { | ||
$this->addError('email', __($status)); | ||
return; | ||
} | ||
$this->reset('email'); | ||
session()->flash('status', __($status)); | ||
}; | ||
?> | ||
|
||
<div> | ||
<div class="mb-4 text-sm text-gray-600 dark:text-gray-400"> | ||
{{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }} | ||
</div> | ||
|
||
<!-- Session Status --> | ||
<x-auth-session-status class="mb-4" :status="session('status')" /> | ||
|
||
<form wire:submit="sendPasswordResetLink"> | ||
<!-- Email Address --> | ||
<div> | ||
<x-input-label for="email" :value="__('Email')" /> | ||
<x-text-input wire:model="email" id="email" class="block mt-1 w-full" type="email" name="email" required autofocus /> | ||
<x-input-error :messages="$errors->get('email')" class="mt-2" /> | ||
</div> | ||
|
||
<div class="flex items-center justify-end mt-4"> | ||
<x-primary-button> | ||
{{ __('Email Password Reset Link') }} | ||
</x-primary-button> | ||
</div> | ||
</form> | ||
</div> |
Oops, something went wrong.