 e958b3761d
			
		
	
	e958b3761d
	
	
	
		
			
			- Introduced `CleanupNames` command to sanitize name fields by removing invalid characters, ensuring only letters, numbers, spaces, dashes, underscores, and dots are retained. - Implemented options for dry run, model-specific cleaning, database backup, and forced execution. - Updated `Init` command to call the new `cleanup:names` command. - Enhanced project and environment validation to enforce name sanitization rules. - Added `HasSafeNameAttribute` trait to relevant models for consistent name handling.
		
			
				
	
	
		
			37 lines
		
	
	
		
			763 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			763 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Models;
 | |
| 
 | |
| use App\Traits\HasSafeNameAttribute;
 | |
| use Illuminate\Database\Eloquent\Casts\Attribute;
 | |
| 
 | |
| class Tag extends BaseModel
 | |
| {
 | |
|     use HasSafeNameAttribute;
 | |
| 
 | |
|     protected $guarded = [];
 | |
| 
 | |
|     public function name(): Attribute
 | |
|     {
 | |
|         return Attribute::make(
 | |
|             get: fn ($value) => strtolower($value),
 | |
|             set: fn ($value) => strtolower($value)
 | |
|         );
 | |
|     }
 | |
| 
 | |
|     public static function ownedByCurrentTeam()
 | |
|     {
 | |
|         return Tag::whereTeamId(currentTeam()->id)->orderBy('name');
 | |
|     }
 | |
| 
 | |
|     public function applications()
 | |
|     {
 | |
|         return $this->morphedByMany(Application::class, 'taggable');
 | |
|     }
 | |
| 
 | |
|     public function services()
 | |
|     {
 | |
|         return $this->morphedByMany(Service::class, 'taggable');
 | |
|     }
 | |
| }
 |