Файловый менеджер - Редактировать - /home/clickysoft/public_html/somni.clickysoft.net/app/Http/Controllers/Admin/LandlordController.php
Назад
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Gate; use Symfony\Component\HttpFoundation\Response; use Spatie\MediaLibrary\MediaCollections\Models\Media; use Yajra\DataTables\Facades\DataTables; use App\Repositories\UserRepository; use App\Interfaces\UserRepositoryInterface; use App\Models\User; use App\Http\Requests\Admin\LandlordCreateRequest; use App\Http\Requests\Admin\LandlordUpdateRequest; class LandlordController extends Controller { private UserRepositoryInterface $userInterfaceObj; private $flag = [0,1]; public function __construct(UserRepository $userRepo){ $this->userInterfaceObj = $userRepo; } /** * Display a listing of the resource. */ public function index(Request $request) { $html = ''; abort_if(Gate::denies('landlord_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); if ($request->ajax()) { $query = User::select(sprintf('%s.*', (new User)->table))->whereHas('roles',function($query){ $query->whereTitle('Landlord'); }); $table = Datatables::of($query); $table->addColumn('placeholder', ' '); $table->addColumn('actions', ' '); $table->editColumn('actions', function ($row) { $viewGate = 'landlord_show'; $editGate = 'landlord_edit'; $deleteGate = 'landlord_delete'; $crudRoutePart = 'landlords'; return view('partials.datatablesActions', compact( 'viewGate', 'editGate', 'deleteGate', 'crudRoutePart', 'row' )); }); $table->editColumn('id', function ($row) { return $row->id; }); $table->addColumn('name', function ($row) { return $row->name ? $row->name : ''; }); $table->editColumn('email', function ($row) { return $row->email ? $row->email : ''; }); $table->editColumn('phone', function ($row) { return $row->phone ? $row->phone : ''; }); $table->editColumn('is_active', function ($row) use ($html) { $html .= '<select class="toggle_status" data-user="'.$row->id.'">'; $html .= ($row->is_active == "Active") ? '<option value="1" selected>'.trans("cruds.landlord.fields.active").'</option><option value="0">'.trans("cruds.landlord.fields.not_active").'</option>': '<option value="1">'.trans("cruds.landlord.fields.active").'</option><option value="0" selected>'.trans("cruds.landlord.fields.not_active").'</option>'; $html .= '</select>'; return $html; }); $table->editColumn('profile_image', function ($row) { // dd($row->profile_image); if ($photo = $row->profile_image) { return sprintf( '<a href="%s" target="_blank"><img src="%s" width="50px" height="50px"></a>', $photo->url, $photo->thumbnail ); } return ''; }); $table->rawColumns(['actions','placeholder', 'profile_image','is_active']); return $table->make(true); } // $users = $this->userInterfaceObj->getLandlords(); return view('admin.landlords.index'); // return view('admin.landlords.index', compact('users')); } /** * Show the form for creating a new resource. */ public function create() { abort_if(Gate::denies('landlord_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); return view('admin.landlords.create'); } /** * Store a newly created resource in storage. */ public function store(LandlordCreateRequest $request) { $user = $this->userInterfaceObj->createUser($request,config('constants.role.landlord')); $users = $this->userInterfaceObj->getLandlords(); return view('admin.landlords.index', compact('users')); } /** * Display the specified resource. */ public function show(User $landlord) { abort_if(Gate::denies('landlord_show'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $landlord->load('properties'); return view('admin.landlords.show',compact('landlord')); } /** * Show the form for editing the specified resource. */ public function edit(User $landlord) { abort_if(Gate::denies('landlord_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); return view('admin.landlords.edit',compact('landlord')); } /** * Update the specified resource in storage. */ public function update(LandlordUpdateRequest $request, $id) { $data = $request; $user = $this->userInterfaceObj->getUserById($id); $flag = $this->userInterfaceObj->updateUser($data,$user); $users = $this->userInterfaceObj->getLandlords(); return redirect()->route('admin.landlords.index'); // return view('admin.landlords.index'); } /** * Remove the specified resource from storage. */ public function destroy($user_id) { abort_if(Gate::denies('landlord_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $user = $this->userInterfaceObj->getUserById($user_id); $user->delete(); return back(); } public function massDestroy(MassDestroyPropertyRequest $request) { $landlords = User::find(request('ids')); foreach ($landlords as $landlord) { $landlord->delete(); } return response(null, Response::HTTP_NO_CONTENT); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка