123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Http\Controllers\Admin\Syj;
- use App\Models\Syj\GroupModel;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class GroupController extends Controller
- {
- //
- public function index()
- {
- $groups = GroupModel::get();
- return response([
- 'code' => 200,
- 'message' => 'OK',
- 'data' => $groups
- ]);
- }
- public function store(Request $request)
- {
- $this->validate($request, [
- 'name' => 'required',
- 'image' => 'required',
- 'capacity_number' => 'required|integer',
- 'total_number' => 'integer|integer',
- 'expired_at' => 'required|integer',
- 'state' => 'integer',
- ]);
- $group = GroupModel::create($request->all());
- return response([
- 'code' => 200,
- 'message' => 'OK',
- 'data' => $group
- ]);
- }
- public function update(Request $request, $id)
- {
- $this->validate($request, [
- 'name' => '',
- 'image' => '',
- 'capacity_number' => 'integer',
- 'total_number' => 'integer',
- 'expired_at' => 'integer',
- 'state' => 'integer',
- ]);
- $group = GroupModel::findOrFail($id);
- $group->update($request->all());
- return response([
- 'code' => 200,
- 'message' => 'Success',
- 'data' => $group
- ]);
- }
- }
|