-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
149 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Concerns\HasUuids; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
|
||
class Statistic extends Model | ||
{ | ||
use HasUuids; | ||
|
||
protected $guarded = []; | ||
|
||
protected $casts = [ | ||
'audio' => 'boolean', | ||
'interpolation' => 'boolean', | ||
'auto_crop' => 'boolean', | ||
'max_size' => 'integer', | ||
'audio_quality' => 'float', | ||
'watermark' => 'boolean', | ||
'created_at' => 'datetime', | ||
'updated_at' => 'datetime', | ||
]; | ||
|
||
public function conversion(): BelongsTo | ||
{ | ||
return $this->belongsTo(Conversion::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
database/migrations/2024_12_24_220649_create_statistics_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::create('statistics', static function (Blueprint $table) { | ||
$table->comment('Each row represents a single conversion'); | ||
|
||
$table->uuid('id')->primary(); | ||
$table->foreignUuid('conversion_id')->nullable()->constrained()->nullOnDelete()->cascadeOnUpdate(); | ||
$table->string('mime_type'); | ||
$table->string('extension'); | ||
$table->string('status'); | ||
$table->boolean('keep_resolution')->default(false); | ||
$table->boolean('audio')->default(true); | ||
$table->boolean('auto_crop')->default(false); | ||
$table->boolean('watermark')->default(false); | ||
$table->boolean('interpolation')->default(false); | ||
$table->float('audio_quality'); | ||
$table->unsignedInteger('trim_start')->nullable(); | ||
$table->unsignedInteger('trim_end')->nullable(); | ||
$table->unsignedInteger('max_size')->nullable(); | ||
$table->text('url')->nullable(); | ||
$table->bigInteger('size'); | ||
$table->dateTime('conversion_started_at')->nullable(); | ||
$table->dateTime('conversion_ended_at')->nullable(); | ||
// create a new generated column for the time difference between conversion_started_at and conversion_ended_at | ||
$table->integer('conversion_time')->virtualAs('TIMESTAMPDIFF(SECOND, conversion_started_at, conversion_ended_at)'); | ||
// virtualAs Column for | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('statistics'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters