Blame view
app/Http/Controllers/CompanyController.php
1.91 KB
7c1e05248 Формы настройки с... |
1 2 3 |
<?php namespace App\Http\Controllers; |
d152a3a68 Создание основных... |
4 |
use App\Models\Employer; |
7c1e05248 Формы настройки с... |
5 6 7 8 |
use Illuminate\Http\Request; class CompanyController extends Controller { |
d152a3a68 Создание основных... |
9 10 |
public function shipping_companies(Request $request) { $emps = Employer::query()->with('ads'); |
a9dfa8c95 Обновление на 7 м... |
11 |
if (($request->has('search')) && (!empty($request->get('search')))) { |
d152a3a68 Создание основных... |
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
$search = $request->get('search'); $emps = $emps->where('name_company', 'LIKE', "%$search%"); } $count_emps = $emps->count(); if ($request->get('sort')) { $sort = $request->get('sort'); switch ($sort) { case 'name_up': $emps = $emps->orderBy('name_company')->orderBy('id'); break; case 'name_down': $emps = $emps->orderByDesc('name_company')->orderby('id'); break; case 'created_at_up': $emps = $emps->OrderBy('created_at')->orderBy('id'); break; case 'created_at_down': $emps = $emps->orderByDesc('created_at')->orderBy('id'); break; case 'default': $emps = $emps->orderBy('id')->orderby('updated_at'); break; default: $emps = $emps->orderBy('id')->orderby('updated_at'); break; } } $emps = $emps->paginate(4); if ($request->ajax()) { if ($request->get('block') == '1') return view('ajax.companies', compact('emps', 'count_emps')); else return view('ajax.companies2', compact('emps', 'count_emps')); } else { return view('companies', compact('emps', 'count_emps')); } } public function info_company(Employer $company) { |
a9dfa8c95 Обновление на 7 м... |
43 44 |
$user_id = Auth()->user()->id; $company = Employer::with('ads')->with('flots')->with('users') |
d152a3a68 Создание основных... |
45 46 |
->where('id', '=', $company->id)->get(); $title = $company[0]->name_company; |
a9dfa8c95 Обновление на 7 м... |
47 |
return view('info_company', compact('company', 'user_id', 'title')); |
d152a3a68 Создание основных... |
48 |
} |
7c1e05248 Формы настройки с... |
49 |
} |