Installing Laravel in a domain subfolder can be useful in certain situations, although it is not officially supported by Laravel creators. In this instruction, I will describe how to configure Laravel 10 in a subfolder and additional tools such as Livewire v3.
This file contains hidden or 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
<?php | |
namespace App\Livewire; | |
use App\Models\Event; | |
use Carbon\Carbon; | |
use Illuminate\Support\Facades\Log; | |
use Illuminate\Support\Facades\Validator; | |
use Livewire\Attributes\Rule; | |
use Livewire\Component; |
This file contains hidden or 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
<?php | |
namespace MarketDragon\LivewireExtra; | |
use Exception; | |
use ReflectionClass; | |
use Illuminate\Filesystem\Filesystem; | |
use Symfony\Component\Finder\SplFileInfo; | |
use Livewire\Component; |
This file contains hidden or 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
<?php | |
namespace App\Http\Livewire; | |
use Livewire\Component; | |
use Livewire\Attributes\Renderless; | |
use App\Traits\HasFilteredReports; | |
class Reports extends Component | |
{ |
This file contains hidden or 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
// open modal from livewire component | |
$this->dispatch('open-modal', name: 'user-details'); | |
// close modal | |
$this->dispatch('close-modal'); |
This file contains hidden or 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
@props(['multiple' => false]) | |
<div {{ $attributes }} wire:ignore x-data="{ | |
value: @entangle($attributes->wire('model')), | |
init(){ | |
let input = new TomSelect(this.$refs.select, { | |
onChange: (value) => this.value = value, | |
items: this.value | |
}); | |
} |
This file contains hidden or 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
<?php | |
namespace App\Http\Livewire; | |
use Livewire\Component; | |
use App\Http\Livewire\Concerns\FormRequest; | |
class ExampleUsage extends Component | |
{ | |
use FormRequest; |
This trait is used to protect public livewire properties from being changed by the user by default in frontend via Livewire JS calls. See: https://www.reddit.com/r/laravel/comments/q0qrri/livewire_extremely_insecure/
If you want to 'expose' methods and properties you must use the $callable and $mutable properties to do so. By default every property defined in $rules or rules() is considered mutable.
This trait will throw an exception if mutable and callable properties are non-existant on your component;
This file contains hidden or 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
<?php | |
namespace App\Http\Livewire\Stats; | |
use Illuminate\Support\Facades\DB; | |
use Livewire\Component; | |
class DistanceByYear extends Component | |
{ | |
public $chartId; |
This file contains hidden or 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
<!doctype html> | |
<title>Site Maintenance</title> | |
<style> | |
body { text-align: center; padding: 150px; } | |
h1 { font-size: 50px; } | |
body { font: 20px Helvetica, sans-serif; color: #333; } | |
article { display: block; text-align: left; width: 650px; margin: 0 auto; } | |
a { color: #dc8100; text-decoration: none; } | |
a:hover { color: #333; text-decoration: none; } | |
</style> |