You've already forked lubo_comment_query
							
							
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Models;
 | |
| 
 | |
| use Illuminate\Database\Eloquent\Casts\Attribute;
 | |
| use Illuminate\Database\Eloquent\Model;
 | |
| use Illuminate\Support\Carbon;
 | |
| 
 | |
| class ProgramVideos extends Model
 | |
| {
 | |
|     protected $fillable = ["start_part", "start_time", "stop_part", "stop_time"];
 | |
|     protected $dateFormat = 'U';
 | |
|     public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo
 | |
|     {
 | |
|         return $this->belongsTo(Programs::class, "program_id", "id");
 | |
|     }
 | |
| 
 | |
|     public function video(): \Illuminate\Database\Eloquent\Relations\BelongsTo
 | |
|     {
 | |
|         return $this->belongsTo(Videos::class, "video_bvid", "bvid");
 | |
|     }
 | |
| 
 | |
|     public function startSec(): Attribute
 | |
|     {
 | |
|         return Attribute::get(function ($_, $attributes) {
 | |
|             if (!isset($attributes['start_time'])) {
 | |
|                 return "";
 | |
|             }
 | |
|             return Carbon::createFromFormat("H:i:s", $attributes['start_time'])->secondsSinceMidnight();
 | |
|         });
 | |
|     }
 | |
| 
 | |
|     public function stopSec(): Attribute
 | |
|     {
 | |
|         return Attribute::get(function ($_, $attributes) {
 | |
|             if (!isset($attributes['stop_time'])) {
 | |
|                 return "";
 | |
|             }
 | |
|             return Carbon::createFromFormat("H:i:s", $attributes['stop_time'])->secondsSinceMidnight();
 | |
|         });
 | |
|     }
 | |
| }
 |