123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
- namespace App\Http\Controllers\Admin;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- /**
- * 大课堂
- * Class WorkTaskController
- * @package App\Http\Controllers\Admin
- */
- class ClassroomController extends Controller
- {
- public function questionsAndAnswers(Request $request)
- {
- $model = DB::table('questions_and_answers');
- if (!$request->ajax()) {
- return view('admin/classroom/questions_and_answers');
- }
- $pageSize = $request->input('pageSize') ?? 10;
- return $this->getList($model, $pageSize);
- }
- public function tool(Request $request)
- {
- $model = DB::table('tool');
- if (!$request->ajax()) {
- return view('admin/classroom/tool');
- }
- $pageSize = $request->input('pageSize') ?? 10;
- return $this->getList($model, $pageSize);
- }
- public function socialMedia(Request $request)
- {
- $model = DB::table('social_media');
- if (!$request->ajax()) {
- return view('admin/classroom/social_media');
- }
- $pageSize = $request->input('pageSize') ?? 10;
- return $this->getList($model, $pageSize);
- }
- public function video(Request $request)
- {
- $model = DB::table('video');
- if (!$request->ajax()) {
- return view('admin/classroom/video');
- }
- return $this->getList($model, $request->input('pageSize') ?? 10);
- }
- public function questionsAndAnswersUpdate(Request $request, $id = 0)
- {
- $model = DB::table('questions_and_answers');
- if (!empty($id)) {
- $info = $model->where('id', $id)->first();
- }
- if (!$request->ajax()) {
- return view('admin/classroom/questions_and_answers_update', [
- 'info' => $info ?? []
- ]);
- }
- $rules = [
- 'title' => 'required|max:255',
- 'content' => 'required',
- ];
- $message = [
- 'title.required' => '标题不能为空',
- 'content.required' => '内容不能为空',
- 'title.max' => '标题不能超过255个字符',
- ];
- return $this->verification($request->all(), $rules, $message, $model, $id);
- }
- public function questionsAndAnswersDelete($id = 0)
- {
- $model = DB::table('questions_and_answers');
- return $this->deleteInfo($model, $id);
- }
- public function toolUpdate(Request $request, $id = 0)
- {
- $model = DB::table('tool');
- if (!empty($id)) {
- $info = $model->where('id', $id)->first();
- }
- if (!$request->ajax()) {
- return view('admin/classroom/tool_update', [
- 'info' => $info ?? []
- ]);
- }
- $rules = [
- 'title' => 'required|max:255',
- 'content' => 'required|max:255',
- 'image' => 'required',
- 'details' => 'required',
- ];
- $message = [
- 'title.required' => '标题不能为空',
- 'content.required' => '内容不能为空',
- 'image.required' => '图片不能为空',
- 'details.required' => '详情不能为空',
- 'title.max' => '标题不能超过255个字符',
- 'content.max' => '内容不能超过255个字符',
- ];
- return $this->verification($request->all(), $rules, $message, $model, $id);
- }
- public function toolDelete($id = 0)
- {
- $model = DB::table('tool');
- return $this->deleteInfo($model, $id);
- }
- public function socialMediaUpdate(Request $request, $id = 0)
- {
- $model = DB::table('social_media');
- if (!empty($id)) {
- $info = $model->where('id', $id)->first();
- }
- if (!$request->ajax()) {
- return view('admin/classroom/social_media_update', [
- 'info' => $info ?? []
- ]);
- }
- $rules = [
- 'title' => 'required|max:255',
- 'content' => 'required|max:255',
- 'image' => 'required',
- 'details' => 'required',
- ];
- $message = [
- 'title.required' => '标题不能为空',
- 'content.required' => '内容不能为空',
- 'image.required' => '图片不能为空',
- 'details.required' => '详情不能为空',
- 'title.max' => '标题不能超过255个字符',
- 'content.max' => '内容不能超过255个字符',
- ];
- return $this->verification($request->all(), $rules, $message, $model, $id);
- }
- public function socialMediaDelete($id = 0)
- {
- $model = DB::table('social_media');
- return $this->deleteInfo($model, $id);
- }
- public function videoUpdate(Request $request, $id = 0)
- {
- $model = DB::table('video');
- if (!empty($id)) {
- $info = $model->where('id', $id)->first();
- }
- if (!$request->ajax()) {
- return view('admin/classroom/video_update', [
- 'info' => $info ?? []
- ]);
- }
- $rules = [
- 'title' => 'required|max:255',
- 'user' => 'required|max:255',
- 'image' => 'required',
- 'video' => 'required|max:255',
- ];
- $message = [
- 'title.required' => '标题不能为空',
- 'user.required' => '发布者姓名不能为空',
- 'image.required' => '图片不能为空',
- 'video.required' => '视频链接不能为空',
- 'title.max' => '标题不能超过255个字符',
- 'user.max' => '发布者姓名不能超过255个字符',
- ];
- return $this->verification($request->all(), $rules, $message, $model, $id);
- }
- public function videoDelete($id = 0)
- {
- $model = DB::table('video');
- return $this->deleteInfo($model, $id);
- }
- }
|