Файловый менеджер - Редактировать - /home/clickysoft/public_html/charliapp-v2.clickysoft.net/app/Http/Controllers/Admin/ColorsController.php
Назад
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Http\Requests\MassDestroyColorRequest; use App\Http\Requests\AdminColorRequest; use App\Models\Calendar; use App\Models\CardTask; use App\Models\Color; use App\Models\Task; use Carbon\Carbon; use Gate; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; use Yajra\DataTables\Facades\DataTables; class ColorsController extends Controller { public function index(Request $request) { abort_if(Gate::denies('color_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); if ($request->ajax()) { $query = Color::query()->select(sprintf('%s.*', (new Color())->table)); $table = Datatables::of($query); $table->addColumn('placeholder', ' '); $table->addColumn('actions', ' '); $table->editColumn('actions', function ($row) { $viewGate = 'color_show'; $editGate = 'color_edit'; $deleteGate = 'color_delete'; $crudRoutePart = 'colors'; return view('partials.datatablesActions', compact( 'viewGate', 'editGate', 'deleteGate', 'crudRoutePart', 'row' )); }); $table->editColumn('id', function ($row) { return $row->id; }); $table->editColumn('color', function ($row) { return $row->color; }); $table->editColumn('color_code', function ($row) { return '<span class="color-block"><span style="background-color: ' . $row->color_code . '"></span>' . $row->color_code . '</span>'; })->escapeColumns('color_code'); $table->editColumn('foreground_color', function ($row) { return '<span class="color-block"><span style="background-color: ' . $row->foreground_color . '"></span>' . $row->foreground_color . '</span>'; }); $table->editColumn('status', function ($row) { return $row->status ? Color::STATUS_RADIO[$row->status] : ''; }); $table->rawColumns(['actions', 'placeholder']); return $table->make(true); } return view('admin.colors.index'); } public function getDashboard(){ $taskCount = Task::where('user_id', auth()->id())->count(); if(!$taskCount){ return response()->json([ "success" => false, "message" => "Invalid Card ID." ], Response::HTTP_NOT_FOUND); } $title = $taskCount; $inProgressCount = Task::where('user_id', auth()->id())->where('status', 'in_progress')->count(); $complete = Task::where('user_id', auth()->id())->where('status','completed')->count(); return response()->json([ "total_task" => $title, "complete"=>$complete, 'inprogress'=>$inProgressCount ], Response::HTTP_OK); } // public function getDashboard(){ // $currentDate = Carbon::now(); // $startDateOfWeek = $currentDate->startOfWeek()->toDateString(); // Get the start date of the current week // $endDateOfWeek = $currentDate->endOfWeek()->toDateString(); // Get the end date of the current week // $calendar = Calendar::selectRaw("'Event' as type, calendars.id, calendars.title, calendars.description, calendars.location, calendars.event_date, calendars.start_time, calendars.end_time, calendars.color_id, colors.color, colors.color_code, colors.foreground_color") // ->where("calendars.user_id", auth()->user()->id) // ->whereBetween('calendars.event_date', [$startDateOfWeek, $endDateOfWeek]) // ->leftJoin("colors", "calendars.color_id", "colors.id")->count(); // $cardTasks = CardTask::selectRaw("'Todo' as type, card_tasks.id, card_tasks.card_id as card_id, card_tasks.todo_item as title, '' as description, '' as location, card_tasks.todo_date as event_date, card_tasks.todo_time as start_time, card_tasks.todo_time as end_time, chapters_cards.color_id, colors.color, colors.color_code, colors.foreground_color") // ->leftJoin("chapters_cards", "card_tasks.card_id", "chapters_cards.id") // ->leftJoin("colors", "chapters_cards.color_id", "colors.id") // ->where("card_tasks.user_id", auth()->user()->id) // ->whereBetween('card_tasks.todo_date', [$startDateOfWeek, $endDateOfWeek]) // ->count(); // return \response()->json(['status'=>true,'task_count'=>$cardTasks,'calender_count'=>$calendar],200); // } // public function getDashboard(){ // $currentDate = Carbon::now(); // $startDateOfWeek = $currentDate->startOfWeek()->toDateString(); // Get the start date of the current week // $endDateOfWeek = $currentDate->endOfWeek()->toDateString(); // Get the end date of the current week // $calendar = Calendar::selectRaw("'Event' as type, calendars.id, calendars.title, calendars.description, calendars.location, calendars.event_date, calendars.start_time, calendars.end_time, calendars.color_id, colors.color, colors.color_code, colors.foreground_color") // ->where("calendars.user_id", auth()->user()->id) // ->whereBetween('calendars.event_date', [$startDateOfWeek, $endDateOfWeek]) // ->leftJoin("colors", "calendars.color_id", "colors.id")->count(); // $cardTasks = CardTask::selectRaw("'Todo' as type, card_tasks.id, card_tasks.card_id as card_id, card_tasks.todo_item as title, '' as description, '' as location, card_tasks.todo_date as event_date, card_tasks.todo_time as start_time, card_tasks.todo_time as end_time, chapters_cards.color_id, colors.color, colors.color_code, colors.foreground_color") // ->leftJoin("chapters_cards", "card_tasks.card_id", "chapters_cards.id") // ->leftJoin("colors", "chapters_cards.color_id", "colors.id") // ->where("card_tasks.user_id", auth()->user()->id) // ->whereBetween('card_tasks.todo_date', [$startDateOfWeek, $endDateOfWeek]) // ->count(); // return \response()->json(['status'=>true,'task_count'=>$cardTasks,'calender_count'=>$calendar],200); // } public function create() { abort_if(Gate::denies('color_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); return view('admin.colors.create'); } public function store(AdminColorRequest $request) { abort_if(Gate::denies('color_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $color = Color::create($request->all()); return redirect()->route('admin.colors.index'); } public function edit(Color $color) { abort_if(Gate::denies('color_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); return view('admin.colors.edit', compact('color')); } public function update(AdminColorRequest $request, Color $color) { abort_if(Gate::denies('color_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $color->update($request->all()); return redirect()->route('admin.colors.index'); } public function show(Color $color) { abort_if(Gate::denies('color_show'), Response::HTTP_FORBIDDEN, '403 Forbidden'); return view('admin.colors.show', compact('color')); } public function destroy(Color $color) { abort_if(Gate::denies('color_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden'); try { $color->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(MassDestroyColorRequest $request) { try { Color::whereIn('id', request('ids'))->delete(); } catch (\Illuminate\Database\QueryException $ex) { return response(["message" => "Record could not be deleted because selected resource is being used."], Response::HTTP_FORBIDDEN); } return response(null, Response::HTTP_NO_CONTENT); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка