Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

realodix/urlhub

532 stars
2 code files
View realodix/urlhub on GitHub

app/Models/Url.php

Open in GitHub
use 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 GitHub
class UrlService
{
public function update(array $request, object $url)
{
$url->long_url = $request['long_url'];
$url->meta_title = $request['meta_title'];
$url->save();
 
return $url;
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.