File: /var/www/ipsremont-demo/app/Models/ActTcAttachment.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $id
* @property int $act_tc_id
* @property string $path
* @property string $original_name
* @property string $created_at
* @property string $updated_at
*
* @property ActTc $actTc
*/
class ActTcAttachment extends BaseModel
{
protected $fillable = [
'act_tc_id',
'path',
'original_name',
];
public function getName(?int $maxWidth = null): string
{
$name = str_replace('app/public/acttc/', '', $this->path);
if (isset($maxWidth) && $maxWidth > 0) {
$name = mb_strimwidth($name, 0, $maxWidth, '...');
}
return $name;
}
// MARK: - Relations
public function actTc(): BelongsTo
{
return $this->belongsTo(ActTc::class);
}
}