Ejemplo n.º 1
0
 public function save(SettingsFormRequest $request)
 {
     $option = new Option();
     if ($option->get('main', 'status') == "firstrun") {
         $option->set('main', 'status', 'running');
     }
     $option->set('settings', 'name', $request->sitename);
     $option->set('settings', 'tagline', $request->tagline);
     $success = "Settings saved.";
     return View::make('admin.settings')->with('success', $success);
 }
Ejemplo n.º 2
0
 public function set($module, $name, $value)
 {
     $option = Option::where('module', $module)->where('option', $name)->first();
     if ($option != null) {
         $option->value = $value;
         $option->save();
     } else {
         $option = new Option();
         $option->module = $module;
         $option->option = $name;
         $option->value = $value;
         $option->save();
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $contacts = Contact::orderBy('id', 'desc')->paginate(10);
     $option = Option::findOrFail(1);
     $featured_properties = Property::where('Heat_inc', '=', 'Yes')->get();
     return view('home', ['contacts' => $contacts, 'option' => $option, 'featured_properties' => $featured_properties]);
 }
Ejemplo n.º 4
0
 /**
  * @param int $offset
  * @param int $count
  * @return array
  * @throws \Exception
  */
 public static function getReviews($offset = 0, $count = 20)
 {
     $response = Vk::call('board.getComments', ['group_id' => Option::get('vk-group-id'), 'topic_id' => Option::get('vk-board-topic-id'), 'offset' => $offset, 'count' => $count]);
     $response = $response['response'];
     $reviews = array_slice($response['comments'], 1);
     return [$response['comments'][0], $reviews];
 }
Ejemplo n.º 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $option = Option::findOrFail($id);
     $option->delete();
     Flash('Option Deleted');
     return Redirect()->route('options');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string $content
  * @return mixed
  */
 public function handle($request, Closure $next, $content)
 {
     $title_separator = Option::get('title_separator');
     //获取标题的分隔符设置值
     Title::addPreffix($content . $title_separator);
     return $next($request);
 }
 public function run()
 {
     $faker = Faker\factory::create();
     DB::table('options')->delete();
     foreach (range(1, 5) as $index) {
         Option::create(['option' => $faker->word]);
     }
 }
Ejemplo n.º 8
0
 protected static function saveAllQuestions($questions, $test)
 {
     foreach ($questions as $question) {
         $savedQuestion = Question::create(['test_id' => $test->id, 'title' => $question['title']]);
         foreach ($question['options'] as $i => $option) {
             Option::create(['question_id' => $savedQuestion->id, 'value' => $option]);
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $currentuser = Auth::user();
     $options = Option::where('module', 'main')->get();
     $name = $options->where('option', 'name')->first()->value;
     $tagline = $options->where('option', 'tagline')->first()->value;
     $modules = Module::orderBy('status', 'desc')->get();
     $navigation = Navigation::where('menu', 'admin')->get();
     $view->with('currentuser', $currentuser)->with('name', $name)->with('tagline', $tagline)->with('modules', $modules)->with('navigation', $navigation);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $tu = $this->userRepository->getTotal();
     $tp = $this->productRepository->getTotal();
     $tc = $this->categoryRepository->getTotal();
     $tt = $this->tagRepository->getTotal();
     $op = Option::count();
     $pm = $this->paymentRepository->getTotal();
     return View('admin.dashboard.index')->with(compact('tu', 'tp', 'tc', 'tt', 'op', 'pm'));
 }
Ejemplo n.º 11
0
 public function saveNewTest($test)
 {
     $newTest = Test::create(['name' => $test['name'], 'preparation' => $test['preparation'], 'time' => $test['time']]);
     // Nested loop to add questions > options
     foreach ($test['questions'] as $question) {
         $savedQuestion = Question::create(['test_id' => $newTest->id, 'title' => $question['title'], 'correct' => $question['correct']]);
         foreach ($question['options'] as $i => $option) {
             Option::create(['question_id' => $savedQuestion->id, 'value' => $option]);
         }
     }
 }
Ejemplo n.º 12
0
 public static function setOption($name, $value)
 {
     if (is_array($value)) {
         $value = json_encode($value);
     }
     if (Option::where('name', $name)->update(['value' => $value, 'updated_at' => current_time()])) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 13
0
 public function run()
 {
     $faker = Faker\factory::create();
     $users = User::lists('id')->All();
     $challenges = Challenge::lists('id')->All();
     $questions = Question::lists('id')->All();
     $options = Option::lists('id')->All();
     foreach (range(1, 5) as $index) {
         User::create(['user_id' => $faker->randomElement($users), 'challenge_id' => $faker->randomElement($challenges), 'active' => $faker->numberBetween($min = 0, $max = 1)]);
     }
 }
Ejemplo n.º 14
0
 public function posts()
 {
     $data = ['group' => ['id' => Option::get('vk-group-id'), 'name' => Option::get('vk-group-name'), 'photo' => Option::get('vk-group-photo'), 'integrated-date' => Carbon::createFromTimestamp(Option::get('vk-group-integrated-date'))]];
     if (Option::has('vk-group-updated-date')) {
         $data['group']['updated-date'] = Carbon::createFromTimestamp(Option::get('vk-group-updated-date'));
     }
     $posts = Post::where('deleted_at', '=', null)->paginate(6);
     $data['posts'] = $posts;
     $display = view('admin.integration.imports.posts', $data)->render();
     return Admin::view($display, 'Записи со стены');
 }
Ejemplo n.º 15
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $data = $request->only('name', 'price');
     try {
         $option = Option::find($id);
         $option->update($data);
         return $option;
     } catch (Exception $e) {
         return $e;
     }
 }
Ejemplo n.º 16
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $title = "Creer Devis";
     $opp = array();
     $categories = Category::all();
     $options = Option::all();
     foreach ($options as $o) {
         $opp[$o->category_id][$o->id] = $o->name;
     }
     return view('Quotations/quotation', ['title' => $title, 'categories' => $categories, 'opp' => $opp]);
 }
Ejemplo n.º 17
0
 public function vote(VoteOnPoll $request)
 {
     $poll = Option::findOrFail($request->input('option.0'))->poll;
     foreach ($request->input('option') as $option) {
         Option::findOrFail($option)->increment('votes');
     }
     if ($poll->ip_checking == 1) {
         $voter = Voter::create(['poll_id' => $poll->id, 'ip_address' => $request->ip()]);
     }
     session()->flash('flash_message', ['title' => 'Success!', 'message' => 'Your vote has been counted.', 'type' => 'success']);
     return redirect('poll/' . $poll->slug . '/result');
 }
Ejemplo n.º 18
0
 public function run()
 {
     $this->command->info('Seeding system options.');
     $option_count = Option::count();
     foreach ($this->slugs() as $slugType => $slugs) {
         foreach ($slugs as $slug) {
             $slug['option_type'] = $slugType;
             $option = Option::updateOrCreate(['option_name' => $slug['option_name']], $slug);
         }
     }
     $option_count = Option::count() - $option_count;
     $this->command->info("Done. Seeded {$option_count} new permission(s).");
 }
Ejemplo n.º 19
0
 public function saveFromNested($test)
 {
     // Clear already existing questions for this particular test.
     Question::where('test_id', $test['id'])->delete();
     foreach ($test['questions'] as $question) {
         $savedQuestion = Question::create(['test_id' => $test['id'], 'title' => $question['title'], 'correct' => $question['correct']]);
         // Clear already existing options for this particular question.
         Option::where('question_id', $savedQuestion['id'])->delete();
         foreach ($question['options'] as $i => $option) {
             Option::create(['question_id' => $savedQuestion->id, 'value' => $option]);
         }
     }
 }
Ejemplo n.º 20
0
 public function fire()
 {
     App::setLocale('en');
     try {
         \DB::table('options')->get();
     } catch (QueryException $exception) {
         $this->error('Run artisan migrate before app install.');
         return;
     }
     if (System::isInstalled()) {
         $this->error('App is already installed.');
         return;
     }
     $siteName = $this->ask('Site Name?');
     $masterUsername = $this->ask('Master Username?');
     $masterEmail = $this->ask('Master Email?');
     $masterPassword = $this->secret('Master Password?');
     $confirmPassword = $this->secret('Confirm Password?');
     $validator = Validator::make(['username' => $masterUsername, 'email' => $masterEmail, 'password' => $masterPassword, 'password_confirmation' => $confirmPassword, 'verification_code_for_username' => '-', 'verification_code_for_email' => '-'], (new SignUpRequest())->rules());
     if ($validator->fails()) {
         foreach ($validator->errors()->all() as $error) {
             $this->error($error);
         }
         return;
     }
     System::setSiteName($siteName);
     $masterRole = new App\Role();
     $masterRole->name = 'Master';
     $masterRole->save();
     System::setMasterRoleId($masterRole->id);
     $adminRole = new App\Role();
     $adminRole->name = 'Administrator';
     $adminRole->save();
     System::setAdministratorRoleId($adminRole->id);
     $editorRole = new App\Role();
     $editorRole->name = 'Editor';
     $editorRole->save();
     System::setEditorRoleId($editorRole->id);
     $defaultRole = new App\Role();
     $defaultRole->name = 'User';
     $defaultRole->save();
     System::setDefaultRoleId($defaultRole->id);
     $user = UserManager::signUp($masterUsername, $masterEmail, null, $masterPassword);
     $user->save();
     $user->roles()->attach($masterRole);
     $user->roles()->attach($adminRole);
     $user->roles()->attach($editorRole);
     $user->roles()->attach($defaultRole);
     Option::setValueByKey('installed', true);
     $this->info('Install success!');
 }
Ejemplo n.º 21
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     setlocale(LC_ALL, 'ru_RU.UTF-8');
     Carbon::setLocale(config('app.locale'));
     \Shortcode::register('slider', '\\App\\Shortcode\\Slider');
     \Shortcode::register('section', '\\App\\Shortcode\\Section');
     \Shortcode::register('iframe', '\\App\\Shortcode\\Iframe');
     \Shortcode::register('timeline', '\\App\\Shortcode\\Timeline');
     if (\DB::getDoctrineSchemaManager()->tablesExist('options')) {
         Option::observe(new OptionObserver());
         if (Option::has('vk-user-token')) {
             Vk::setAccessToken(Option::get('vk-user-token'));
         }
     }
 }
Ejemplo n.º 22
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request)
 {
     Cache::forget('system-options');
     $requests = $request->except(['_token', '_method']);
     $options = Option::latest()->get();
     foreach ($options as $option) {
         if ($requests[$option->name] != $option->value) {
             $option->value = htmlspecialchars($requests[$option->name]);
             $option->save();
         }
         $data[$option->name] = $option->value;
     }
     Cache::forever('system-options', $data);
     flash()->message('修改成功!');
     return redirect()->back();
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //If user hasn't selected any options, carry on to form validation / rejection
     if (!$request->input('option.0')) {
         return $next($request);
     }
     $poll = Option::findOrFail($request->input('option.0'))->poll;
     //if we already have this user's IP stored and linked to the poll they are trying to vote on
     //flash an error and redirect to results.
     if ($poll->ip_checking == 1) {
         if (Voter::where('ip_address', '=', $request->ip())->where('poll_id', '=', $poll->id)->exists()) {
             session()->flash('flash_message_confirm', ['title' => 'Error!', 'message' => 'You have already vote on this poll. Your vote has not been counted.', 'type' => 'error']);
             return redirect('poll/' . $poll->slug . '/result');
         }
     }
     return $next($request);
 }
Ejemplo n.º 24
0
 public function run()
 {
     $this->command->info('Seeding system options.');
     $option_count = Option::count();
     foreach ($this->slugs() as $slugType => $slugs) {
         foreach ($slugs as $slug) {
             $slug['option_type'] = $slugType;
             if (!isset($slug['format_parameters']) || is_null($slug['format_parameters'])) {
                 $slug['format_parameters'] = "{}";
             }
             $option = Option::updateOrCreate(['option_name' => $slug['option_name']], $slug);
             // Insert a default site setting.
             if ($option->wasRecentlyCreated && $slugType == "site") {
                 $option->siteSetting()->create(['option_name' => $slug['option_name'], 'option_value' => $slug['default_value']]);
             }
         }
     }
     $option_count = Option::count() - $option_count;
     $this->command->info("Done. Seeded {$option_count} new permission(s).");
 }
Ejemplo n.º 25
0
 /**
  * Get all the scenario data for the game to start
  *
  * @return JSON data
  */
 public function getStartupData()
 {
     $newOptions = $newPeople = array();
     $scenarios = Scenario::all();
     $options = Option::all();
     $people = OptionPerson::all();
     foreach ($scenarios as &$s) {
         foreach ($options as $o) {
             foreach ($people as $p) {
                 if ($p['option_id'] == $o['id']) {
                     $newPeople[] = array('person_id' => $p['person_id'], 'fatigue' => $p['fatigue'], 'motivation1' => $p['motivation1'], 'motivation2' => $p['motivation2'], 'option_id' => $p['option_id']);
                 }
             }
             if ($o['scenario_id'] == $s['id']) {
                 $newOptions[] = array('name' => $o['name'], 'hint' => $o['hint'], 'description' => $o['description'], 'people' => $newPeople);
             }
             $newPeople = array();
         }
         $s['options'] = $newOptions;
         $newOptions = array();
     }
     return $scenarios;
 }
Ejemplo n.º 26
0
 private function prepareData($data)
 {
     $descriptionPayment = "";
     $total = 0;
     $product = Product::findOrFail($data['product_id']);
     if ($product->option_id) {
         $product->published = 1;
         $product->featured = $product->option_id != 1 ? $product->featured = 1 : 0;
         $product->save();
         $option = Option::findOrFail($product->option_id);
         $descriptionPayment .= $option->name . ' ' . $option->price;
         $total += $option->price;
     }
     if ($product->tags->count()) {
         $descriptionPayment .= ' - Etiqueta: ' . $product->tags->first()->name . ' ' . $product->tags->first()->price;
         $total += $product->tags->first()->price;
     }
     $data = array_add($data, 'user_id', auth()->user()->id);
     $data = array_add($data, 'description', $descriptionPayment);
     $data = array_add($data, 'amount', $total);
     $data = array_add($data, 'operationNumber', $data['purchaseOperationNumber']);
     return $data;
 }
Ejemplo n.º 27
0
 /**
  * Renders public config.
  *
  * @param  \App\Board  $board
  * @return REsponse
  */
 public function getConfig(Board $board)
 {
     return Option::andBoardSettings($board)->get();
 }
Ejemplo n.º 28
0
 /**
  * Obtain the user information from vkontakte.
  *
  * @return Response
  */
 public function handleProviderCallback()
 {
     $user = Socialite::with('vkontakte')->user();
     Option::set('vk-user-id', $user->id);
     Option::set('vk-user-name', $user->name);
     Option::set('vk-user-avatar', $user->avatar);
     Option::set('vk-user-token', $user->token);
     Option::set('vk-user-integrated-date', time());
     Session::flash('flash_message', 'vk-user-integrated');
     Session::flash('flash_type', 'success');
     return redirect(route('admin.integration'));
 }
Ejemplo n.º 29
0
 public function setStatus($value)
 {
     $status = Option::where('option', 'status')->first();
     $status->set('main', 'status', $value);
     $status->save();
 }
Ejemplo n.º 30
0
 /**
  * @param $attachmentData
  * @param $data
  */
 protected static function _prepareAttachmentPoll($attachmentData, &$data)
 {
     $pollData = $attachmentData['poll'];
     $data['type'] = $attachmentData['type'];
     $data['id'] = Option::get('vk-group-id') . '_' . $pollData['poll_id'];
     $data['title'] = 'В записи имеется голосование, подробности смотрите в источнике.';
 }