mgsmus ikiside
frontendde stiller ve classlar gelmiyordu ama yarım yamalak hallettim
şimdi ise
<div class="flex items-center mr-2 sm:mr-4 space-x-2">
<label class="relative inline-flex h-6 w-[46px] items-center rounded-full transition-all duration-150 cursor-pointer">
<input type="checkbox" value="{{$post?->status== '1' ? '0' : '1'}}" {{$post?->status== '1' ? 'checked' : ''}} id="status{{$key}}" onchange="Status('{{$post?->general_key}}','{{$key}}',this.value,'/posts/status')" class="sr-only peer">
<div class="w-14 h-6 bg-gray-200 peer-focus:outline-none ring-0 rounded-full peer dark:bg-gray-900 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:z-10 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-500"></div>
<span class="absolute left-1 z-20 text-xs text-white font-Inter font-normal opacity-0 peer-checked:opacity-100">On</span>
<span class="absolute right-1 z-20 text-xs text-white font-Inter font-normal opacity-100 peer-checked:opacity-0">Off</span>
</label>
</div>
şöyle bir yapım vardı
ben datatablese çevirdikten sonra şöyle yaptım
$posts = $this->postsRepository->postsIndex();
$route = '/posts/status';
return DataTables::of($posts)
->addIndexColumn()
->addColumn('action', function ($post) {
// Add edit button with post ID as a route parameter
return '<a href="'.route('postsEditIndex', $post->general_key).'">Edit</a>';
})
->addColumn('change_status', function ($post) use ($route) {
return View::make('layouts.status_toggle', ['status' => $post->status, 'key' => $post->general_key, 'permission' => 'posts_status', 'route' => $route])->render();
})
->addColumn('slider_status_action', function ($post) use ($route) {
return View::make('layouts.status_toggle', ['status' => $post->is_slide, 'key' => $post->general_key, 'permission' => 'posts_slider_status', 'route' => $route])->render();
})
->editColumn('status', function ($post) {
// Add a button to toggle the status with a unique ID for each row
// return '<button class="change-status-btn" data-post-id="'.$post->id.'">Toggle Status</button>';
return $post->status == 1 ?
'<div id="statusdata'.$post->id.'" class="inline-block px-3 min-w-[90px] text-center mx-auto py-1 rounded-[999px] bg-opacity-25 text-success-500 bg-success-500">Active</div>'
:
'<div id="statusdata'.$post->id.'" class="inline-block px-3 min-w-[90px] text-center mx-auto py-1 rounded-[999px] bg-opacity-25 text-danger-500 bg-danger-500">Deactive</div>';
})
->editColumn('slider_status', function ($post) {
// Add a button to toggle the slider status with a unique ID for each row
return $post->is_slide == 1 ?
'<div id="statusdata'.$post->id.'" class="inline-block px-3 min-w-[90px] text-center mx-auto py-1 rounded-[999px] bg-opacity-25 text-success-500 bg-success-500">Active</div>'
:
'<div id="statusdata'.$post->id.'" class="inline-block px-3 min-w-[90px] text-center mx-auto py-1 rounded-[999px] bg-opacity-25 text-danger-500 bg-danger-500">Deactive</div>';
})
->rawColumns(['action', 'status', 'slider_status', 'change_status', 'slider_status_action'])
->make(true);
<!-- resources/views/partials/status_toggle.blade.php -->
@can($permission)
<div class="flex items-center mr-2 sm:mr-4 space-x-2">
<label class="relative inline-flex h-6 w-[46px] items-center rounded-full transition-all duration-150 cursor-pointer">
<input type="checkbox" value="{{ $status == '1' ? '0' : '1' }}"
{{ $status == '1' ? 'checked' : '' }} onchange="Status('{{ $key }}', this.value, '@route($route)')"
class="sr-only peer">
<div
class="w-14 h-6 bg-gray-200 peer-focus:outline-none ring-0 rounded-full peer dark:bg-gray-900 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:z-10 after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-500">
</div>
<span
class="absolute left-1 z-20 text-xs text-white font-Inter font-normal opacity-0 peer-checked:opacity-100">
On
</span>
<span
class="absolute right-1 z-20 text-xs text-white font-Inter font-normal opacity-100 peer-checked:opacity-0">
Off
</span>
</label>
</div>
@endcan
şimdide bana şöyle bir hata veriyor
The POST method is not supported for route posts/text-post. Supported methods: GET, HEAD.
halbuki posts/text-post route verilerin listelendiği route ben isteği '/posts/status' yapıyorum
ayrıca
payloadda
_token: AWaHvGwv56qOhPhs1p0hvE6nsO0dMGE34rHrwQIX
id: 2e5eb8ddeb133763350ace98aa8663c3
status: @route($route)