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
<div x-data="{ open: false }"> | |
<button @click="open = true">Open Dropdown</button> | |
<ul | |
x-show="open" | |
@click.away="open = false" | |
> | |
Dropdown Body | |
</ul> | |
</div> |
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
<!-- Blade, e.g. welcome.blade.php --> | |
<form action="{{ route('form.submit') }}" method="POST" class="space-y-4"> | |
@csrf | |
<div> | |
@error('fullname') | |
<div class="text-red-500">{{ $message }}</div> | |
@enderror | |
<label for="fullname">Fullname</label> |
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
// routes/web.php | |
validate([ | |
'fullname' => 'required|alpha|min:3', | |
]); | |
return 'Submission allowed'; | |
})->name('form.submit'); | |
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
public function handle($request, Closure $next) | |
{ | |
if (! auth()->user()->is_admin) | |
{ | |
abort(403); | |
} | |
return $next($request); | |
} |
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
private function create_user(is_admin = 0) | |
{ | |
$this->user = factory(User::class)->create([ | |
'is_admin' => $is_admin, | |
]); | |
} |
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
$response = $this->post('login', [ | |
'email' => 'EMAIL', | |
'password' => 'PW' | |
]); | |
// assert where you expect to be redirected to, e.g. home | |
$response->assertRedirect('/home'); |
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
public rules() { | |
return [ | |
'name' => 'required', | |
'price' => 'required', | |
]; | |
} |
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
public function destroy(Product $product) { | |
$product->delete(); | |
return redirect()->route('products.index'); | |
} |
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
id) }} method="POST" onsubmit="confirm('Sure?')"> | |
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
$response = $this->actingAs($this->user) | |
->put('/products/' . $product->id, | |
[ | |
'name' => 'Test', | |
'price' => 99.99, | |
], | |
[ | |
'Accept' => 'Application/json', | |
]); |
NewerOlder