Initial commit
This commit is contained in:
30
app/Http/Livewire/Mailings/.php-cs-fixer.dist.php
Normal file
30
app/Http/Livewire/Mailings/.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
|
||||
|
||||
return (new Config())
|
||||
->setParallelConfig(ParallelConfigFactory::detect()) // @TODO 4.0 no need to call this manually
|
||||
->setRiskyAllowed(false)
|
||||
->setRules([
|
||||
'@auto' => true
|
||||
])
|
||||
// 💡 by default, Fixer looks for `*.php` files excluding `./vendor/` - here, you can groom this config
|
||||
->setFinder(
|
||||
(new Finder())
|
||||
// 💡 root folder to check
|
||||
->in(__DIR__)
|
||||
// 💡 additional files, eg bin entry file
|
||||
// ->append([__DIR__.'/bin-entry-file'])
|
||||
// 💡 folders to exclude, if any
|
||||
// ->exclude([/* ... */])
|
||||
// 💡 path patterns to exclude, if any
|
||||
// ->notPath([/* ... */])
|
||||
// 💡 extra configs
|
||||
// ->ignoreDotFiles(false) // true by default in v3, false in v4 or future mode
|
||||
// ->ignoreVCS(true) // true by default
|
||||
)
|
||||
;
|
||||
130
app/Http/Livewire/Mailings/LocationFilter.php
Normal file
130
app/Http/Livewire/Mailings/LocationFilter.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Mailings;
|
||||
|
||||
use App\Models\Locations\City;
|
||||
use App\Models\Locations\Country;
|
||||
use App\Models\Locations\District;
|
||||
use App\Models\Locations\Division;
|
||||
use Livewire\Component;
|
||||
|
||||
class LocationFilter extends Component
|
||||
{
|
||||
public $selectedCountries = [];
|
||||
public $selectedDivisions = [];
|
||||
public $selectedCities = [];
|
||||
public $selectedDistricts = [];
|
||||
|
||||
public $countries = [];
|
||||
public $divisions = [];
|
||||
public $cities = [];
|
||||
public $districts = [];
|
||||
|
||||
protected $listeners = ['resetLocationFilter', 'loadLocationFilterData'];
|
||||
|
||||
public function mount($selectedCountries = [], $selectedDivisions = [], $selectedCities = [], $selectedDistricts = [])
|
||||
{
|
||||
$this->selectedCountries = $selectedCountries;
|
||||
$this->selectedDivisions = $selectedDivisions;
|
||||
$this->selectedCities = $selectedCities;
|
||||
$this->selectedDistricts = $selectedDistricts;
|
||||
|
||||
$this->loadLocationData();
|
||||
}
|
||||
|
||||
public function loadLocationData()
|
||||
{
|
||||
// Always load all countries
|
||||
$this->countries = Country::with(['translations'])->get();
|
||||
|
||||
// Load divisions if any countries are selected
|
||||
if (!empty($this->selectedCountries)) {
|
||||
$this->divisions = Division::with(['translations'])
|
||||
->whereIn('country_id', $this->selectedCountries)
|
||||
->get();
|
||||
} else {
|
||||
$this->divisions = collect();
|
||||
}
|
||||
|
||||
// Load cities if any countries are selected
|
||||
if (!empty($this->selectedCountries)) {
|
||||
$this->cities = City::with(['translations'])
|
||||
->whereIn('country_id', $this->selectedCountries)
|
||||
->get();
|
||||
} else {
|
||||
$this->cities = collect();
|
||||
}
|
||||
|
||||
// Load districts if any cities are selected
|
||||
if (!empty($this->selectedCities)) {
|
||||
$this->districts = District::with(['translations'])
|
||||
->whereIn('city_id', $this->selectedCities)
|
||||
->get();
|
||||
} else {
|
||||
$this->districts = collect();
|
||||
}
|
||||
}
|
||||
|
||||
public function updatedSelectedCountries()
|
||||
{
|
||||
// Reset lower levels when countries change
|
||||
$this->selectedDivisions = [];
|
||||
$this->selectedCities = [];
|
||||
$this->selectedDistricts = [];
|
||||
|
||||
$this->loadLocationData();
|
||||
$this->emitSelectionUpdate();
|
||||
}
|
||||
|
||||
public function updatedSelectedDivisions()
|
||||
{
|
||||
$this->emitSelectionUpdate();
|
||||
}
|
||||
|
||||
public function updatedSelectedCities()
|
||||
{
|
||||
// Reset districts when cities change
|
||||
$this->selectedDistricts = [];
|
||||
$this->loadLocationData();
|
||||
$this->emitSelectionUpdate();
|
||||
}
|
||||
|
||||
public function updatedSelectedDistricts()
|
||||
{
|
||||
$this->emitSelectionUpdate();
|
||||
}
|
||||
|
||||
public function resetLocationFilter()
|
||||
{
|
||||
$this->selectedCountries = [];
|
||||
$this->selectedDivisions = [];
|
||||
$this->selectedCities = [];
|
||||
$this->selectedDistricts = [];
|
||||
$this->loadLocationData();
|
||||
$this->emitSelectionUpdate();
|
||||
}
|
||||
|
||||
public function loadLocationFilterData($data)
|
||||
{
|
||||
$this->selectedCountries = $data['countries'] ?? [];
|
||||
$this->selectedDivisions = $data['divisions'] ?? [];
|
||||
$this->selectedCities = $data['cities'] ?? [];
|
||||
$this->selectedDistricts = $data['districts'] ?? [];
|
||||
$this->loadLocationData();
|
||||
}
|
||||
|
||||
private function emitSelectionUpdate()
|
||||
{
|
||||
$this->dispatch('locationFilterUpdated', [
|
||||
'countries' => $this->selectedCountries,
|
||||
'divisions' => $this->selectedDivisions,
|
||||
'cities' => $this->selectedCities,
|
||||
'districts' => $this->selectedDistricts,
|
||||
]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.mailings.location-filter');
|
||||
}
|
||||
}
|
||||
1210
app/Http/Livewire/Mailings/Manage.php
Normal file
1210
app/Http/Livewire/Mailings/Manage.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user