Update
parent
1ba8ad3847
commit
882cb76b98
|
|
@ -135,28 +135,4 @@ class Dealer extends Model
|
||||||
return $item->dealer;
|
return $item->dealer;
|
||||||
})->all();
|
})->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 变更经销商等级
|
|
||||||
*
|
|
||||||
* @param DealerLvl $lvl
|
|
||||||
* @param string $remark
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function changeLvl(DealerLvl $lvl, string $remark = null)
|
|
||||||
{
|
|
||||||
$beforeLvl = $this->lvl;
|
|
||||||
|
|
||||||
$this->update([
|
|
||||||
'lvl' => $lvl,
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($this->wasChanged('lvl')) {
|
|
||||||
$this->lvlUpgradeLogs()->create([
|
|
||||||
'change_lvl' => $this->lvl,
|
|
||||||
'before_lvl' => $beforeLvl,
|
|
||||||
'remark' => $remark,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use App\Enums\DealerLvl;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
class DealerLvlUpgradeLog extends Model
|
|
||||||
{
|
|
||||||
protected $casts = [
|
|
||||||
'change_lvl' => DealerLvl::class,
|
|
||||||
'before_lvl' => DealerLvl::class,
|
|
||||||
];
|
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'user_id',
|
|
||||||
'change_lvl',
|
|
||||||
'before_lvl',
|
|
||||||
'remark',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class CreateDealerLvlUpgradeLogsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::create('dealer_lvl_upgrade_logs', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->unsignedBigInteger('user_id');
|
|
||||||
$table->tinyInteger('change_lvl')->comment('变更后的等级');
|
|
||||||
$table->tinyInteger('before_lvl')->comment('变更前的等级');
|
|
||||||
$table->string('remark')->nullable()->comment('备注');
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('dealer_lvl_upgrade_logs');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue