Файловый менеджер - Редактировать - /home/clickysoft/public_html/charliapp-v2.clickysoft.net/app/Http/Controllers/Admin/TimelinesController.php
Назад
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Http\Requests\MassDestroyTimelineRequest; use App\Http\Requests\AdminTimelineRequest; use App\Models\User; use App\Models\Book; use App\Models\Color; use App\Models\Series; use App\Models\Timeline; use Gate; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; use Yajra\DataTables\Facades\DataTables; class TimelinesController extends Controller { public function index(Request $request) { abort_if(Gate::denies('timeline_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); if ($request->ajax()) { $query = Timeline::with(['user', 'series', 'book', 'color'])->select(sprintf('%s.*', (new Timeline())->table)); $table = Datatables::of($query); $table->addColumn('placeholder', ' '); $table->addColumn('actions', ' '); $table->editColumn('actions', function ($row) { $viewGate = 'timeline_show'; $editGate = 'timeline_edit'; $deleteGate = 'timeline_delete'; $crudRoutePart = 'timelines'; $tableName = 'timelines'; return view('partials.datatablesActions', compact( 'viewGate', 'editGate', 'deleteGate', 'crudRoutePart', 'row', 'tableName' )); }); $table->editColumn('id', function ($row) { return $row->id; }); $table->editColumn('name', function ($row) { return $row->name; }); // $table->editColumn('description', function ($row) { // return $row->description ? $row->description : ''; // }); $table->editColumn('user_name', function ($row) { return $row->user->name; }); $table->addColumn('series_series_name', function ($row) { return $row->series ? $row->series->series_name : ''; }); $table->addColumn('book_book_name', function ($row) { return $row->book ? $row->book->book_name : ''; }); $table->addColumn('color_color', function ($row) { return $row->color ? '<span class="color-block"><span style="background-color: ' . $row->color->color_code . '"></span>' . $row->color->color . '</span>' : ''; })->escapeColumns('color_color'); $table->editColumn('status', function ($row) { return '<span id="recordSts' . $row->id . '"><i class="sts fa fa-' . ($row->status == 1 ? "check" : "times") . '"></i> ' . Timeline::STATUS_RADIO[$row->status] . '</span>'; }); $table->rawColumns(['actions', 'placeholder', 'series', 'book', 'color']); return $table->make(true); } $users = User::get(); $seriess = []; //Series::get(); $books = []; //Book::get(); $colors = Color::get(); return view('admin.timelines.index', compact('users', 'seriess', 'books', 'colors')); } public function create() { abort_if(Gate::denies('timeline_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $users = User::pluck('name', 'id')->prepend(trans('global.pleaseSelect'), ''); $series = []; //Series::pluck('series_name', 'id')->prepend(trans('global.pleaseSelect'), ''); $books = []; //Book::pluck('book_name', 'id')->prepend(trans('global.pleaseSelect'), ''); $colors = Color::select("id", "color", "color_code", "foreground_color")->get(); return view('admin.timelines.create', compact('users', 'books', 'colors', 'series')); } public function store(AdminTimelineRequest $request) { $timeline = Timeline::create($request->all()); return redirect()->route('admin.timelines.index'); } public function edit(Timeline $timeline) { abort_if(Gate::denies('timeline_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $users = User::pluck('name', 'id')->prepend(trans('global.pleaseSelect'), ''); $series = Series::whereUserId($timeline->user_id)->pluck('series_name', 'id')->prepend(trans('global.pleaseSelect'), ''); $books = Book::whereSeriesId($timeline->series_id)->pluck('book_name', 'id')->prepend(trans('global.pleaseSelect'), ''); $colors = Color::select("id", "color", "color_code", "foreground_color")->get(); $users = User::pluck('name', 'id')->prepend(trans('global.pleaseSelect'), ''); return view('admin.timelines.edit', compact('users', 'books', 'colors', 'series', 'timeline')); } public function update(AdminTimelineRequest $request, Timeline $timeline) { $timeline->update($request->all()); return redirect()->route('admin.timelines.index'); } public function show(Timeline $timeline) { abort_if(Gate::denies('timeline_show'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $timeline->load('series', 'book', 'color'); return view('admin.timelines.show', compact('timeline')); } public function destroy(Timeline $timeline) { abort_if(Gate::denies('timeline_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden'); try { $timeline->delete(); } catch (\Illuminate\Database\QueryException $ex) { return redirect()->back()->withErrors("Record could not be deleted because selected resource is being used."); } return back(); } public function massDestroy(MassDestroyTimelineRequest $request) { try { Timeline::whereIn('id', request('ids'))->delete(); } catch (\Illuminate\Database\QueryException $ex) { return redirect()->back()->withErrors("Record could not be deleted because selected resource is being used."); } return response(null, Response::HTTP_NO_CONTENT); } public function getTimelineByBook($book_id) { $timelines = Timeline::selectRaw("id, name as title")->whereSeriesId($book_id)->get(); return response()->json(["list" => $timelines]); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка