| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/project-slim/app/Models/ |
Upload File : |
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CompanySocial extends BaseModel
{
/**
* The table associated with the model.
*/
protected $table = 'repo_company_social';
/**
* The primary key for the model.
*/
protected $primaryKey = 'social_id';
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'company_id',
'platform',
'handle',
'url'
];
/**
* The attributes that should be hidden for serialization.
* Inherits from BaseModel to hide all ID fields
*/
protected $hidden = [
'id',
'social_id',
'company_id',
'user_id',
'role_id',
'report_id',
'module_id'
];
/**
* Get the company that owns the social link.
*/
public function company(): BelongsTo
{
return $this->belongsTo(Company::class, 'company_id', 'company_id');
}
/**
* Get formatted platform name.
*/
public function getFormattedPlatformAttribute(): string
{
return ucfirst($this->platform);
}
/**
* Generate URL if not provided but handle exists.
*/
public function getGeneratedUrlAttribute(): ?string
{
if ($this->url) {
return $this->url;
}
if (!$this->handle) {
return null;
}
return match ($this->platform) {
'linkedin' => "https://linkedin.com/company/{$this->handle}",
'twitter', 'x' => "https://twitter.com/{$this->handle}",
'instagram' => "https://instagram.com/{$this->handle}",
'youtube' => "https://youtube.com/@{$this->handle}",
'facebook' => "https://facebook.com/{$this->handle}",
default => null
};
}
}