mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-21 02:20:54 +08:00
HitAndRun
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class HitAndRun extends NexusModel
|
||||
{
|
||||
protected $table = 'hit_and_runs';
|
||||
|
||||
protected $fillable = ['uid', 'peer_id', 'torrent_id', 'status', 'comment'];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
const STATUS_INSPECTING = 1;
|
||||
const STATUS_PASSED = 2;
|
||||
const STATUS_NOT_PASSED = 3;
|
||||
const STATUS_CANCELED = 4;
|
||||
|
||||
public static $status = [
|
||||
self::STATUS_INSPECTING => ['text' => '考察中'],
|
||||
self::STATUS_PASSED => ['text' => '已通过'],
|
||||
self::STATUS_NOT_PASSED => ['text' => '未通过'],
|
||||
self::STATUS_CANCELED => ['text' => '已取消'],
|
||||
];
|
||||
|
||||
public function getStatusTextAttribute()
|
||||
{
|
||||
return self::$status[$this->status] ?? '';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateHitAndRunsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('hit_and_runs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('uid')->index();
|
||||
$table->integer('peer_id')->unique();
|
||||
$table->integer('torrent_id')->index();
|
||||
$table->integer('status')->default(1);
|
||||
$table->string('comment')->default('');
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('hit_and_runs');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user