You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
		
		
		
		
		
			
		
			
				
					
					
						
							43 lines
						
					
					
						
							872 B
						
					
					
				
			
		
		
	
	
							43 lines
						
					
					
						
							872 B
						
					
					
				| <?php | |
| 
 | |
| namespace App\Models; | |
| 
 | |
| use App\Utils\S3; | |
| use Illuminate\Database\Eloquent\Model; | |
| 
 | |
| class Album extends Model | |
| { | |
|     protected $fillable = [ | |
|         'name', | |
|         'path', | |
|         'uuid', | |
|         'user_id' | |
|     ]; | |
| 
 | |
|     public function jsonSerialize():array  | |
|     { | |
|         return [ | |
|             'uuid' => $this->uuid, | |
|             'name' => $this->name, | |
|             'path' => $this->path,  | |
|             'image' => S3::signUrl($this->path), | |
|             'user' => $this->user, | |
|             'created_at' => date("d.m.Y", strtotime($this->created_at)), | |
|         ]; | |
|     } | |
| 
 | |
|     public function user()  | |
|     { | |
|         return $this->belongsTo(User::class); | |
|     } | |
| 
 | |
|     public function photos() | |
|     { | |
|         return $this->belongsToMany(Photo::class)->withTimestamps(); | |
|     } | |
| 
 | |
|     public function tags() | |
|     { | |
|         return $this->belongsToMany(Tag::class)->withTimestamps(); | |
|     } | |
| }
 | |
| 
 |