Aşağıdaki şekilde dener misiniz?
Migration
Schema::create('marketing_plans', function (Blueprint $table) {
$table->id();
$table->string('private_key')->unique();
$table->timestamps();
$table->softDeletes();
$table->foreignId('user_id')->constrained()->onDelete('cascade')->nullable();
$table->foreignId('branch_id')->constrained()->onDelete('cascade')->nullable();
$table->foreignId('competitor_market_id')->constrained()->onDelete('cascade')->nullable();
$table->json('one_week')->nullable();
$table->json('two_week')->nullable();
$table->json('three_week')->nullable();
$table->json('four_week')->nullable();
$table->json('five_week')->nullable();
$table->json('six_week')->nullable();
$table->json('seven_week')->nullable();
$table->json('eight_week')->nullable();
});
Model(ekleyiniz)
protected $casts = [
'one_week' => 'array',
'two_week' => 'array',
'three_week' => 'array',
'four_week' => 'array',
'five_week' => 'array',
'six_week' => 'array',
'seven_week' => 'array',
'eight_week' => 'array'
];
View
<tbody>
@foreach($activities as $activity)
<tr>
<td class="fixed">
{{ $activity->name }}
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('one_week[]', $activity->id, in_array($activity->id, $marketingPlan->one_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('one_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('two_week[]', $activity->id, in_array($activity->id, $marketingPlan->two_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('two_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('three_week[]', $activity->id, in_array($activity->id, $marketingPlan->three_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('three_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('four_week[]', $activity->id, in_array($activity->id, $marketingPlan->four_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('four_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('five_week[]', $activity->id, in_array($activity->id, $marketingPlan->five_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('five_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('six_week[]', $activity->id, in_array($activity->id, $marketingPlan->six_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('six_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('seven_week[]', $activity->id, in_array($activity->id, $marketingPlan->seven_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('seven_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
<td class="fixed text-center">
@if (isset($marketingPlan))
{{ Form::checkbox('eight_week[]', $activity->id, in_array($activity->id, $marketingPlan->eight_week) ? true : false, ['class' => 'name']) }}
@else
{{ Form::checkbox('eight_week[]', $activity->id, false, ['class' => 'name']) }}
@endif
</td>
</tr>
@endforeach
</tbody>
Service
MarketingPlan::create($request->all());