Initial commit

This commit is contained in:
Ronald Huynen
2026-03-23 21:37:59 +01:00
commit 2547717edb
2193 changed files with 972171 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
<?php
namespace App\Http\Livewire\ProfileOrganization;
use Livewire\Component;
use WireUi\Traits\WireUiActions;
class UpdateSocialMediaForm extends Component
{
use WireUiActions;
public $profile;
public $website;
protected $listeners = ['emitSaved'];
public function rules()
{
return [
'website' => 'regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/',
];
}
/**
* Prepare the component.
*
* @return void
*/
public function mount()
{
$this->profile = session('activeProfileType')::find(session('activeProfileId'));
$this->website = $this->profile['website'];
}
/**
* Validate a single field when updated.
* This is the 1st validation method on this form.
*
* @param mixed $field
* @return void
*/
public function updated($field)
{
if ($field = 'website') {
$this->website = $this->addUrlScheme($this->website);
}
$this->validateOnly($field);
}
public function emitSaved()
{
$this->dispatch('saved');
}
/**
* Update the organization's profile contact information.
*
* @return void
*/
public function update()
{
$this->validate(); // 2nd validation, just before save method
$this->profile->website = str_replace(['http://', 'https://', ], '', $this->website);
$this->profile->save();
$this->dispatch('saved');
}
public function addUrlScheme($url, $scheme = 'https://')
{
return parse_url($url, PHP_URL_SCHEME) === null ?
$scheme . $url : $url;
}
public function render()
{
return view('livewire.profile-organization.update-social-media-form');
}
}