上报数据任务增加店长

main
Jing Li 2024-04-17 10:27:21 +08:00
parent 0a9fe3dc4a
commit 4ca6e78619
3 changed files with 7 additions and 3 deletions

View File

@ -63,7 +63,7 @@ class TaskLedgerGenerateCommand extends Command
return $planable->setRelation('plan', $plan); return $planable->setRelation('plan', $plan);
}); });
$stores = Store::all(); $stores = Store::with(['master'])->all();
/** @var \App\Models\Store */ /** @var \App\Models\Store */
foreach ($stores as $store) { foreach ($stores as $store) {
@ -71,6 +71,8 @@ class TaskLedgerGenerateCommand extends Command
$taskable = TaskLedger::firstOrNew([ $taskable = TaskLedger::firstOrNew([
'store_id' => $store->id, 'store_id' => $store->id,
'date' => $planable->date, 'date' => $planable->date,
], [
'store_master_id' => $store->master?->id,
]); ]);
if ($taskable->exists) { if ($taskable->exists) {

View File

@ -13,8 +13,9 @@ class TaskLedger extends Model
use HasFactory, HasDateTimeFormatter; use HasFactory, HasDateTimeFormatter;
protected $fillable = [ protected $fillable = [
'store_id',
'date', 'date',
'store_id',
'store_master_id',
]; ];
public function task(): MorphOne public function task(): MorphOne

View File

@ -13,8 +13,9 @@ return new class extends Migration
{ {
Schema::create('task_ledgers', function (Blueprint $table) { Schema::create('task_ledgers', function (Blueprint $table) {
$table->id(); $table->id();
$table->foreignId('store_id')->comment('门店ID');
$table->date('date')->comment('日期'); $table->date('date')->comment('日期');
$table->foreignId('store_id')->comment('门店ID');
$table->foreignId('store_master_id')->comment('店长');
$table->timestamps(); $table->timestamps();
}); });
} }