/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $setting = Settings::where('company_id', '=', Auth::user()->company_id)->where('application_id', '=', 1)->where('references_id', '=', 0)->first(); $ref = Settings::where('company_id', '=', Auth::user()->company_id)->where('references_id', '=', 1)->where('application_id', '=', 0)->first(); //dd($setting); return view('settings.index', compact('setting', 'ref')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['subject' => 'required|max:255', 'product' => 'required', 'group' => 'required', 'severity' => 'required', 'description' => 'required']); $settings = Settings::where('name', 'ticket_track_id')->first(); $track_id = $settings->str_value; $customer = Customer::where('id', $this->my_customer_id)->first(); $search_strings = ['%COMPANY_NAME', '%Y', '%m', '%d']; $value_strings = [str_replace(' ', '_', $customer->name), date('Y', time()), date('m', time()), date('d', time())]; $track_id = str_replace($search_strings, $value_strings, $track_id); $ticket = Ticket::create(['subject' => $request->subject, 'track_id' => $track_id, 'description' => $request->description, 'group_id' => $request->group, 'severity_id' => $request->severity, 'product_id' => $request->product, 'user_id' => $this->my_id, 'customer_id' => $this->my_customer_id, 'status_id' => 1]); if (isset($request->attachments)) { foreach ($request->attachments as $attachment) { // Check that the directory exists $uploadPath = storage_path() . '/attachments/' . $ticket->id; $fs = new Filesystem(); if (!$fs->isDirectory($uploadPath)) { // Create the directory $fs->makeDirectory($uploadPath); } $attachment->move($uploadPath, $attachment->getClientOriginalName()); $_attachment = Attachment::create(['user_id' => $this->my_id, 'name' => $attachment->getClientOriginalName(), 'ticket_id' => $ticket->id]); } } $this->dispatch(new EmailNewTicket($ticket)); return redirect('/tickets'); }
public function update(Request $request) { $settings = Settings::getUserSettings(Auth::user()->id); $this->validate($request, ['nickname' => 'required']); Settings::where('user_id', Auth::user()->id)->update(['nickname' => $request->input('nickname'), 'enable_chat' => $request->input('enable_chat'), 'editor_font' => $request->input('editor_font'), 'editor_font_color' => $request->input('editor_font_color')]); return redirect('/settings'); }
/** * Execute the job. * * @return void */ public function handle(Mailer $mail) { $group = $this->ticket->group_id; $customers = Group::where('id', $group)->first()->customers()->get(); $_customers = []; foreach ($customers as $customer) { $_customers[] = $customer->id; } $sys_name = Settings::where('name', 'sys_name')->first(); $user = User::whereIn('customer_id', $_customers)->get(); foreach ($user as $_user) { $mail->send('emails.updateticket', ['user' => $_user, 'ticket' => $this->ticket, 'response' => $this->response, 'sys_name' => $sys_name], function ($m) use($_user) { $m->to($_user->email, $_user->first_name . ' ' . $_user->last_name)->subject('Ticket updated - ' . $this->ticket->track_id . ' [' . $this->ticket->status->name . ']'); if (count($this->response->attachments()->get()) > 0) { foreach ($this->response->attachments as $attachment) { $m->attach(storage_path() . '/attachments/' . $this->ticket->id . '/' . $attachment->name); } } }); } // Cleanup variables unset($this->ticket); unset($this->response); unset($group); unset($customers); unset($user); unset($sys_name); unset($_customers); }
public static function getUserSettings($user_id) { $default_settings = ['user_id' => $user_id, 'nickname' => Auth::user()->username, 'enable_chat' => 1, 'editor_font' => 'Consolas', 'editor_font_color' => 'Black']; if (!Settings::where('user_id', $user_id)->exists()) { $settings = Settings::create($default_settings); } else { $settings = Settings::where('user_id', $user_id)->first(); } return $settings; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function save(Request $request) { $departments = $request->get('department'); foreach ($departments as $id => $department) { Settings::where('department_id', $id)->delete(); foreach ($department as $key => $value) { Settings::create(['department_id' => $id, 'key' => $key, 'value' => $value]); } } return redirect()->action('Admin\\SettingsController@display')->with('success', 'updated'); }
/** * Export PDF application form * * @param Request $request * @return \Illuminate\Http\Response */ public function exportApplication(Request $request) { $name = 'application'; $pdfFilename = urlencode(strtolower($name . '-' . date('d-m-Y') . '.pdf')); $ref = References::where('applications_id', '=', $request->segment(4))->first(); $refOne = References::where('id', $request->input('ref_one'))->first(); $refTwo = References::where('id', $request->input('ref_two'))->first(); $settings = Settings::where('company_id', '=', Auth::user()->company_id)->where('references_id', '=', 0)->first(); $custom = Fields::where('settings_id', $settings->id)->where('application_id', '=', $request->segment(4))->get(); $pdf = PDF::loadView('pdf.application', compact('refOne', 'refTwo', 'ref', 'custom', 'settings')); return $pdf->download($pdfFilename); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { foreach ($request->input('setting') as $key => $value) { $setting = Settings::where('name', $key); if ($setting->get()->count() > 0) { $setting->first()->update(['name' => $key, 'value' => $value]); } else { Settings::create(['name' => $key, 'value' => $value]); } } return back()->withSuccess('Settings saved successfully!'); }
public static function get($cell, $name) { $retval = 'undefined'; if ($name == Settings::INITIAL_EMPTY_POSITIONS || $name == Settings::PERIODIC_EMPTY_POSITION) { $retval = 0; } try { $results = Settings::where(array('cell' => $cell, 'name' => $name))->firstOrFail(); $retval = $results->value; } catch (\Exception $e) { } return $retval; }
/** * Edit the Settings. * * @return Response */ public function postSettings(Request $request) { $settings = $request->all(); $oldSettings = Settings::where('id', '!=', '')->first(); // Rename and upload file if ($request->file('logo')) { $file = $request->file('logo'); $fileName = str_random(6) . '_' . $file->getClientOriginalName(); $file->move(public_path() . '/uploads', $fileName); $settings['logo'] = $fileName; } $oldSettings->fill($settings); $oldSettings->save(); return Redirect('/admin/settings')->with('message', Lang::get('admin/settings/message.edit.success')); }
/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { $data = Tool::removeSpace($request->all()); $validator = Validator::make($data, ["hora_prueba" => "required|valid_time", "duración_prueba" => "required|valid_minute"]); $toArray = $validator->errors()->toArray(); if ($validator->fails()) { return redirect()->back()->withInput()->withErrors($validator->errors()); } $chedumalTrial = Settings::where('field', '=', 'Schedumal_trial')->first(); $durationTrial = Settings::where('field', '=', 'Duration_trial')->first(); if ($chedumalTrial->value != $data['hora_prueba']) { DB::table('rb_settings')->where('field', 'Schedumal_trial')->update(['value' => $data['hora_prueba']]); } if ($durationTrial->value != $data['duración_prueba']) { DB::table('rb_settings')->where('field', 'Duration_trial')->update(['value' => $data['duración_prueba']]); } return $this->index(); }
public function update(Request $request) { $data = $request->all(); foreach (Settings::$default as $name => $key) { if (isset($data[$name])) { $data[$name] = is_array($data[$name]) ? json_encode($data[$name]) : $data[$name]; Settings::where('name', $name)->update(['value' => $data[$name]]); } } $user_data = ['name' => $data['name'], 'email' => $data['admin_email']]; if ($data['password']) { if ($data['password'] != $data['password_confirm']) { return back()->withErrors(trans('admin/settings.message.password_not_match')); } $user_data['password'] = bcrypt($data['password']); } User::find(1)->update($user_data); return back()->with(['message' => trans('admin/settings.message.update_success')]); }
public static function durationTrial() { $data = Settings::where('field', '=', 'Duration_trial')->first(); return $data->value; }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->command('inspire')->hourly(); $schedule->call(function () { // Ищем аукционы, дата завершения которых подошла к концу $auctionsEnd = Auction::where('date_end', '=', Carbon::parse(Carbon::now())->format('Y-m-d H:i'))->where('status', '=', 3)->with('bidders')->get(); // Если такие аукционы есть if ($auctionsEnd->count() > 0) { foreach ($auctionsEnd as $auction) { // Данные пользователя создавшего аукцион $user = User::find($auction->user); // Определяем победителя по наибольшей ставке $win = Bets::where('auction_id', '=', $auction->id)->orderBy('created_at', 'desc')->first(); // Помещаем аукцион в Архив $auction->in_archive = 1; /* * Если победитель есть */ if ($win) { // Загружаем информацию о победителе $win_user = User::find($win->user_id); // Присваиваем участнику статус "Победитель" $win_status = Bidders::where('auction_id', '=', $auction->id)->where('user_id', '=', $win->user_id)->first(); $win_status->status = 2; $win_status->save(); // Смена статуса на "Торги відбулися" $auction->status = 7; $auction->final_price = $win->bet; // Окончательная цена $auction->save(); // Отправка письма создателю аукциона Mail::queue('emails.auction-end', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'middle_name' => $user->middle_name, 'auction_id' => $auction->id, 'auction_title' => $auction->title, 'auction_cyr' => $auction->currency, 'auction_status' => 7, 'win_first_name' => $win_user->first_name, 'win_last_name' => $win_user->last_name, 'win_middle_name' => $win_user->middle_name, 'win_email' => $win_user->email, 'win_phone' => $win_user->phone, 'win_cost' => $win->bet], function ($message) use($user) { $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Аукціон завершено'); }); // Отправка письма победителю аукциона Mail::queue('emails.auction-end-winner', ['first_name' => $win_user->first_name, 'last_name' => $win_user->last_name, 'auction_id' => $auction->id, 'auction_title' => $auction->title, 'auction_cyr' => $auction->currency, 'auction_status' => 7, 'win_cost' => $win->bet], function ($message) use($win_user) { $message->to($win_user->email, $win_user->first_name . ' ' . $win_user->last_name)->subject('Аукціон завершено'); }); // Отправка письма администратору $adminEmail = Config::get('app.admin_email'); Mail::queue('emails.auction-end-admin', ['auction_id' => $auction->id, 'auction_title' => $auction->title, 'auction_status' => 7, 'auction_cyr' => $auction->currency, 'win_first_name' => $win_user->first_name, 'win_last_name' => $win_user->last_name, 'win_middle_name' => $win_user->middle_name, 'win_email' => $win_user->email, 'win_phone' => $win_user->phone, 'win_cost' => $win->bet], function ($message) use($adminEmail) { $message->to($adminEmail)->subject('Аукціон завершено'); }); } else { $auction->status = 8; // Смена статуса на "Торги не відбулися" $auction->save(); // Отправка письма создателю аукциона Mail::queue('emails.auction-end', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'middle_name' => $user->middle_name, 'auction_id' => $auction->id, 'auction_title' => $auction->title, 'auction_status' => 8], function ($message) use($user) { $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Аукціон завершено'); }); // Отправка письма администратору $adminEmail = Config::get('app.admin_email'); Mail::queue('emails.auction-end-admin', ['auction_id' => $auction->id, 'auction_title' => $auction->title, 'auction_status' => 8], function ($message) use($adminEmail) { $message->to($adminEmail)->subject('Аукціон завершено'); }); } } } })->everyMinute(); $schedule->call(function () { // Ищем аукционы, которые должны начаться $auctions = Auction::where('data_start', '=', Carbon::parse(Carbon::now())->format('Y-m-d H:i'))->where('status', '=', 2)->with('bidders')->get(); // Если количество аукционов больше нуля, выполняем скрипт if ($auctions->count() > 0) { foreach ($auctions as $auction) { $user = User::find($auction->user); // Информация о создателе аукциона // Если к началу аукциона есть участники - выполняем if ($auction->bidders->count() > 0) { $array[$auction->id] = []; $bid = []; $auction->status = 3; $auction->save(); foreach ($auction->bidders as $bidder) { // Если статус участника "Допущено" if ($bidder->status == 1) { $array[$auction->id] = array_add($array[$auction->id], 'id', $auction->id); $array[$auction->id] = array_add($array[$auction->id], 'title', $auction->title); array_push($bid, $bidder->user_id); } } $array[$auction->id] = array_add($array[$auction->id], 'bidders', $bid); // Получаем доступ к информации о каждом участнике $users[$auction->id] = User::find($array[$auction->id]['bidders']); foreach ($users[$auction->id] as $user) { Mail::queue('emails.auctionstart', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'auction_id' => $auction->id, 'auction_title' => $auction->title], function ($message) use($user) { $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Розпочато аукціон'); }); } } else { $auction->status = 8; // Смена статуса на "Торги не відбулися" $auction->in_archive = 1; // Помещаем аукцион в Архив $auction->save(); // Отправка письма создателю аукциона Mail::queue('emails.auction-end', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'middle_name' => $user->middle_name, 'auction_id' => $auction->id, 'auction_title' => $auction->title, 'auction_status' => 8], function ($message) use($user) { $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Аукціон завершено'); }); // Отправка письма администратору $adminEmail = Config::get('app.admin_email'); Mail::queue('emails.auction-end-admin', ['auction_id' => $auction->id, 'auction_title' => $auction->title, 'auction_status' => 8], function ($message) use($adminEmail) { $message->to($adminEmail)->subject('Аукціон завершено'); }); } } } })->everyMinute(); $schedule->call(function () { // Ищем аукционы, которые должны начаться через 10 минут $auctions = Auction::where('data_start', '=', Carbon::parse(Carbon::now())->addMinutes(10)->format('Y-m-d H:i'))->where('status', '=', 2)->with('bidders')->get(); // Если количество аукционов больше нуля, выполняем скрипт if ($auctions->count() > 0) { foreach ($auctions as $auction) { // Если к началу аукциона есть участники - выполняем if ($auction->bidders->count() > 0) { $array[$auction->id] = []; $bid = []; foreach ($auction->bidders as $bidder) { // Если статус участника "Допущено" if ($bidder->status == 1) { $array[$auction->id] = array_add($array[$auction->id], 'id', $auction->id); $array[$auction->id] = array_add($array[$auction->id], 'title', $auction->title); array_push($bid, $bidder->user_id); } } $array[$auction->id] = array_add($array[$auction->id], 'bidders', $bid); // Получаем доступ к информации о каждом участнике $users[$auction->id] = User::find($array[$auction->id]['bidders']); foreach ($users[$auction->id] as $user) { Mail::queue('emails.auctionstart10', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'auction_id' => $auction->id, 'auction_title' => $auction->title], function ($message) use($user) { $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Аукціон розпочнеться через 10 хвилин'); }); } $user = User::find($auction->user); // Информация о создателе аукциона // Отправка письму о начале через 10 минут создателю аукциона Mail::queue('emails.auctionstart10creator', ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'auction_id' => $auction->id, 'auction_title' => $auction->title], function ($message) use($user) { $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Ваш аукціон розпочнеться через 10 хвилин'); }); } } } })->everyMinute(); /* * Ежедневная проверка курса доллара и евро * В случае несовпадения курса банка с курсом на сайте - курс изменяется */ $schedule->call(function () { $currentUSD = \App\Settings::where(['name' => 'usd_cyr'])->first(); // Текущий курс доллара $currentEUR = \App\Settings::where(['name' => 'eur_cyr'])->first(); // Текущий курс евро $currentUSDval = $currentUSD->value; $currentEURval = $currentEUR->value; $get_currency = 'https://api.privatbank.ua/p24api/pubinfo?exchange&json&coursid=11'; $currency = file_get_contents($get_currency); $currency = json_decode($currency); $newCurrencyUSD = number_format($currency[0]->sale, 2, '.', ' '); // Новый курс доллара $newCurrencyEUR = number_format($currency[1]->sale, 2, '.', ' '); // Новый курс евро if ($currentUSDval != $newCurrencyUSD) { $currentUSD->value = $newCurrencyUSD; $currentUSD->save(); } if ($currentEURval != $newCurrencyEUR) { $currentEUR->value = $newCurrencyEUR; $currentEUR->save(); } })->daily(); }
public function getAuctionPageBySlug($id, $slug) { try { $auction = Auction::where('id', '=', $id)->where('slug', '=', $slug)->firstOrFail(); // Если аукцион не утвержден его сможет просматривать только администратор if ($auction->status == 0) { if (Auth::check()) { if (Auth::user()->is_admin != 1) { abort(404); } } else { abort(404); } } } catch (\Exception $e) { // Если запись не найдена - показываем 404 ошибку abort(404); } // Выбираем документы лота $documents = Uploads::where(['auction_id' => $id, 'type' => 'doc'])->get(); // Текуший курс доллара из настроек $currentUSD = Cache::remember('currentUSD', 10, function () { return Settings::where(['name' => 'usd_cyr'])->first(); }); // Текуший евро доллара из настроек $currentEUR = Cache::remember('currentEUR', 10, function () { return Settings::where(['name' => 'eur_cyr'])->first(); }); $haveBidder = 0; $Bidder = null; // Загружаем участников аукциона $Bidder = Auction::with('bidders')->with('curuser')->find($id); // Загружаем ставки $Bets = Bets::where('auction_id', '=', $id)->orderBy('created_at', 'desc')->get(); // Если пользователь авторизован if (Auth::check()) { // Проверка, является ли текущий пользователь участником $BidderCurrent = Bidders::where('user_id', '=', Auth::user()->id)->where('auction_id', '=', $id)->get(); $haveBidder = $BidderCurrent->count(); } return view('auction.lots.single', ['auction' => $auction, 'documents' => $documents, 'haveBidder' => $haveBidder, 'Bidders' => $Bidder, 'Bets' => $Bets, 'currentUSD' => $currentUSD, 'currentEUR' => $currentEUR]); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $setting = Settings::where('id', $id)->first(); if ($request->type == 'str') { $setting->str_value = $request->val; } else { $setting->int_value = $request->val; } $setting->update(); $settings = Settings::where('id', $id)->first(); if ($settings->group_name == 'SMTP' || $settings->group_name == 'Email') { $this->dispatch(new UpdateMailConfig($settings)); } }
public function index(Request $request) { return view('admin.settings.settings_list', ['modelData' => Settings::where('setting_show_in_admin', 1)->get()]); }
/** * Обновляет настройки сайта */ public function postSettings(Request $request) { $rules = []; // Правила обработки $allSettings = App\Settings::all(); foreach ($allSettings as $item) { if ($item->rules) { $rules = array_add($rules, $item->name, $item->rules); } } // Валидация $this->validate($request, $rules); // Обновление данных каждого поля foreach ($request->except('_token') as $i => $val) { App\Settings::where('name', $i)->update(['value' => $val]); } // Удаляем закешированные настройки if (Cache::has('settings')) { Cache::forget('settings'); } // Возврашаем сообщение об успешном обновлении Session::flash('success', 'Данные успешно обновлены'); return redirect()->back(); }
/** * Submit Reference * * @param Request $request */ public function submitReference(Request $request) { $code = $request->segment(2); $segment = \Request::url(); $search = ['http://', 'https://', '.madesimpleapp', '.co.uk/', \Request::segment(1) . '/', \Request::segment(2) . '/', \Request::segment(3)]; $replace = ['', '', '', '', '', '', '']; $output = str_replace($search, $replace, $segment); $company = Company::where('url', $output)->first(); $referee = References::where('code', $code)->first(); $settings = Settings::where('company_id', $company->id)->where('references_id', '=', 1)->get(); return view('references.submit', compact('referee', 'company', 'code', 'settings')); }
public function refereeSubmittedTwo(Request $request) { $code = $request->segment(2); $refTwo = References::where('id', $request->input('referee_id'))->first(); $refTwo->referee_name = $request->input('name'); $refTwo->referee_start_date = $request->input('applicant_started'); $refTwo->referee_end_date = $request->input('date_left'); $refTwo->referee_email = $request->input('email_address'); $refTwo->position = $request->input('position'); $refTwo->leaving = $request->input('reason_for_leaving'); $refTwo->completedtwo = 'Yes'; $refTwo->re_employ = $request->input('re_employ'); $refTwo->update(); $fields = Fields::create($request->except('_token', 're_employ', 'referee_id', 'first_name', 'middle_name', 'surname', 'name', 'phone', 'position', 'email_address', 'applicant_started', 'date_left', 'reason_for_leaving', 'code')); //$settings = Settings::create($request->only('label', 'label2', 'label3', 'label4', 'label5', 'label6', 'label7', 'label8', 'label9', 'label10', 'company_id')); $settings = Settings::where('id', $refTwo->settings_id)->first(); $settings->fields_id = $fields->id; $settings->update(); $apps = Applications::where('code', $code)->first(); $apps->reference_two_id = $refTwo->id; $apps->update(); $fields->settings_id = $settings->id; $fields->references_id = $refTwo->id; $fields->update(); $segment = \Request::url(); $search = ['http://', 'https://', '.madesimpleapp', '.co.uk/', \Request::segment(1) . '/', \Request::segment(2) . '/', \Request::segment(3)]; $replace = ['', '', '', '', '', '', '']; $output = str_replace($search, $replace, $segment); $company = Company::where('url', $output)->first(); $refTwo->settings_id = $settings->id; $refTwo->company_id = $company->id; $refTwo->applications_id = $apps->id; $refTwo->update(); flash()->success('Success', 'Thank you for submission'); return redirect('/'); }
public function settings() { return Settings::where('id', '!=', '')->first(); }