Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/public_html/app/Modules/Schedules/Http/Controllers/Admin/ |
<?php
namespace App\Modules\Schedules\Http\Controllers\Admin;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\Controller;
use App\Modules\Postcodes\Models\District;
use App\Modules\Schedules\Models\TableMassageDistrict;
use Illuminate\Http\Request;
class TableMassageController extends AdminController
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$tm_list = [];
foreach(TableMassageDistrict::all() as $tm)
$tm_list[$tm->district_id] = $tm->display;
$this->data['page_title'] = trans('schedules::table.page_title');
$this->data['districts'] = District::all();
$this->data['values'] = $tm_list;
return view('schedules::admin.massage_table.table_district_index', $this->data);
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function store(Request $request)
{
//truncate table
TableMassageDistrict::truncate();
//values
$values = $request->all();
$districts = District::all();
foreach($districts as $d){
$data = [
'district_id' => $d->id,
'display' => $values["district_{$d->id}"],
];
TableMassageDistrict::create($data);
} //endforeach
//redirect
return redirect(route('admin.schedules.table.index'));
}
}