Blame view
app/Providers/MyServiceProvider.php
3.36 KB
5f2a2635a Справочник Должно... |
1 2 3 |
<?php namespace App\Providers; |
5b68533bb Работа над проект... |
4 |
use App\Models\Company; |
077a30c8a Таблица контента ... |
5 |
use App\Models\ContentRoles; |
e3c7b0ffb Коммит на понедел... |
6 |
use App\Models\Employer; |
5f2a2635a Справочник Должно... |
7 |
use App\Models\Job_title; |
e3c7b0ffb Коммит на понедел... |
8 |
use App\Models\Worker; |
f060aa75b Счетчик сообщений... |
9 10 |
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; |
5f2a2635a Справочник Должно... |
11 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 43 44 45 46 47 48 49 50 51 52 |
use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; class MyServiceProvider extends ServiceProvider { /** * Register services. * * @return void */ public function register() { // } /** * Bootstrap services. * * @return void */ public function boot() { $views = ['admin.job_titles.parent_id']; View::composer($views, function($view) { static $items = null; if (is_null($items)) { $items = Job_title::query()-> orderByDesc('sort')-> orderBy('name')-> active()-> get(); $parent = 0; $view->with(['items' => $items, 'parent' => $parent]); } else { $view->with(['items' => $items]); } } ); |
f060aa75b Счетчик сообщений... |
53 |
|
00652ea57 Оптимизация запро... |
54 |
$views2 = ['layout.admin', 'admin.index']; |
f060aa75b Счетчик сообщений... |
55 56 57 58 |
View::composer($views2, function($view){ $id = Auth::user()->id; |
077a30c8a Таблица контента ... |
59 60 61 62 |
$is_manager = Auth::user()->is_manager; $admin = Auth::user()->admin; $contents = ContentRoles::query()->get(); |
f060aa75b Счетчик сообщений... |
63 64 65 66 67 |
$query = DB::select(DB::raw('SELECT count(*) as MsgCount FROM messages m1 Where ((m1.flag_new = 1) and (m1.to_user_id = :uid)) '), ['uid' => $id] ); |
077a30c8a Таблица контента ... |
68 69 70 71 72 |
$view->with(['MsgCount' => $query[0]->MsgCount, 'UserId' => $id, 'is_manager' => $is_manager, 'admin' => $admin, 'contents' => $contents]); |
f060aa75b Счетчик сообщений... |
73 74 |
} ); |
5b68533bb Работа над проект... |
75 76 77 78 79 80 81 82 83 84 85 |
$views3 = ['layout.frontend']; View::composer($views3, function($view){ $id = Auth::user(); $companies = Company::query()->limit(1)->get(); $view->with(['UserId' => $id, 'companies' => $companies]); } ); |
e3c7b0ffb Коммит на понедел... |
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
$view1 = ['employers.menu', 'employers.emblema', 'employers.send_all']; View::composer($view1, function($view){ $user = Auth::user(); $id = $user->id; $employer = Employer::query()->where('user_id', $id)->get(); $id_employer = $employer[0]->id; $view->with(['id_employer' => $id_employer, 'Employer' => $employer]); } ); $view_worker = ['workers.emblema']; View::composer($view_worker, function($view_worker) { $user = Auth::user(); $id = $user->id; $Worker = Worker::query()->where('user_id', $id)->get(); $id_worker = $Worker[0]->id; $view_worker->with(['id_worker' => $id_worker, 'Worker' => $Worker, 'User' => $user]); } ); |
5f2a2635a Справочник Должно... |
108 109 |
} } |