上报数据任务增加店长

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

View File

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

View File

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