-
app/Models/Url.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; class Url extends Model { public function setMetaTitleAttribute($value) { $urlSrvc = new UrlService(); if (Str::startsWith($value, 'http')) { $this->attributes['meta_title'] = $urlSrvc->webTitle($value); } else { $this->attributes['meta_title'] = $value; } } }
-
app/Services/UrlService.php
Open in GitHubclass UrlService { public function update(array $request, object $url) { $url->long_url = $request['long_url']; $url->meta_title = $request['meta_title']; $url->save(); return $url; } }