protected function addToCart($data)
 {
     if (empty($data['product_ids'])) {
         return false;
     }
     $store = $this->owner;
     $options = $store->getOptionsByName();
     if (!empty($options['add_to_cart_counter_statistics'])) {
         $option = $options['add_to_cart_counter_statistics'];
     } else {
         $option = new Option();
         $option->name = 'add_to_cart_counter_statistics';
         $option->link('store', $store);
     }
     $stats = [];
     if ($option->value) {
         $stats = Json::decode($option->value);
     }
     foreach ($data['product_ids'] as $product_id) {
         if (empty($stats[$product_id])) {
             $stats[$product_id] = 0;
         }
         $stats[$product_id]++;
     }
     $option->value = Json::encode($stats);
     $option->save();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // SET UP NEW CARBON DATES
     $_old = '2016/san-antonio';
     $_new = (object) ['slug' => '2017/san-antonio', 'published' => Carbon::create(2016, 01, 18, 16, 30, 00), 'start' => Carbon::create(2017, 01, 18, 07, 00, 00), 'end' => Carbon::create(2017, 01, 18, 16, 30, 00)];
     // DELETE DUPLICATES
     $conference = Conference::where('slug', '=', $_new->slug)->delete();
     $forceDel = Conference::onlyTrashed()->forceDelete();
     $agenda = Agenda::where('conference_slug', '=', $_new->slug)->delete();
     $forceDel = Agenda::onlyTrashed()->forceDelete();
     $option = Option::where('slug', '=', $_new->slug)->delete();
     $forceDel = Option::onlyTrashed()->forceDelete();
     unset($conference, $agenda, $option, $forceDel);
     // RESCHEDULE CONFERENCE
     $conference = Conference::where('slug', '=', $_old)->update(['slug' => $_new->slug, 'start_date' => $_new->start, 'end_date' => $_new->end, 'published' => $_new->published]);
     // UPDATE OPTIONS
     $option = Option::where('slug', '=', $_old)->update(['slug' => $_new->slug]);
     // UPDATE AGENDA
     $agendas = Agenda::where('conference_slug', '=', $_old)->get();
     foreach ($agendas as $agenda) {
         $agenda->conference_slug = $_new->slug;
         $agenda->timeslot = $_new->start->format('Y-m-d') . ' ' . $agenda->timeslot->format('H:i:s');
         $agenda->save();
     }
     // UPDATE SPEAKERS
     $speakers = Speaker::where('conference_slug', '=', $_old)->update(['conference_slug' => $_new->slug]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Variables for later use
     $slug = '2016/austin';
     $date = Carbon::parse('2016-09-21 00:00:00');
     $published = Carbon::parse('2016-07-22 13:53:12');
     // Turn off the topics since we have a fleshed out agenda
     Option::where('slug', '=', $slug)->where('option', '=', 'show_topics')->where('value', '=', 1)->update(['value' => 0]);
     // Update remaining agenda items
     // 9:00 Keynote
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->addHours(9)->format('Y-m-d H:i:s'))->update(['slug' => 'staffing-training-and-talent-retention', 'session_type' => 'keynote', 'title' => 'Staffing, Training & Talent Retention', 'title_short' => 'Staffing, Training & Talent Retention', 'desc' => 'Join our opening panel of CIOs as we discuss challenges around staffing, training and how to keep our good talent from leaving.  With new technological advances coming out all the time, we often need people with new types of advanced knowledge and skillsets.  Do we hire and retrain people from within the organization or do we look to the pool of people coming from the universities or other areas?  Join our panel as they discuss what they are doing to recruit and retrain technical staff, where they are finding their IT Talent and some of the things that they are doing to retain their good talent from leaving to find new opportunities.']);
     // 10:30 Keynote
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->addHour()->addMinutes(30)->format('Y-m-d H:i:s'))->orderBy('priority', 'asc')->take(1)->update(['slug' => 'cyber-security', 'session_type' => 'keynote', 'title' => 'Cyber Security', 'title_short' => 'Cyber Security', 'desc' => 'With cyber threats evolving, IT Leaders are challenged to find more innovative ways to secure and protect information while increasing access to authorized users. Join our discussion as we talk about some of the security challenges and risks that comes with each. Discussion points will include: Personal vs. Corporate mobile devices and how to protect them, Multi factor authentication, the paradigm of web based applications, access to cloud networks and interactive real time infrastructures.']);
     // Disable the second 10:30 breakout
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->format('Y-m-d H:i:s'))->orderBy('priority', 'desc')->take(1)->update(['published' => null]);
     // 11:45 Breakouts
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->addHour()->addMinutes(15)->format('Y-m-d H:i:s'))->orderBy('priority', 'asc')->take(1)->update(['slug' => 'business-continuity-disaster-recovery', 'session_type' => 'breakout', 'title' => 'Business Continuity Disaster Recovery', 'title_short' => 'Business Continuity Disaster Recovery', 'desc' => 'Having an established business continuity and disaster recovery plan can help an organization to continue business and mitigate losses during catastrophic failures, cyber-attacks and malware infections, natural disasters and other critical emergencies. Join our group of experts as they discuss some of the strategies and protocols which have been implemented to help protect their companies in the event that an emergency strikes.']);
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->format('Y-m-d H:i:s'))->orderBy('priority', 'desc')->take(1)->update(['slug' => 'new-technology-trends', 'session_type' => 'session', 'title' => 'New Technology Trends', 'title_short' => 'New Technology Trends', 'desc' => 'What is on the Horizon?']);
     // 12:45 Keynote
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->addHour()->format('Y-m-d H:i:s'))->update(['slug' => 'the-internet-of-things', 'session_type' => 'keynote', 'title' => 'The Internet of Things', 'title_short' => 'The Internet of Things', 'desc' => 'As Technology advances, so has the capability to simultaneously connect devices, buildings, vehicles, networks, electronics, power grids, software, sensors and much more, giving us the ability to share, collect and use data in real time. Where the Internet of Things can provide convenience and benefits to the organization, it can also cause an IT organization many challenges. Join our panel of experts as they discuss how they are using IOT along with some of the significant challenges and benefits in moving to this type of technology.']);
     // 2:30 Breakouts
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->addHour()->addMinutes(45)->format('Y-m-d H:i:s'))->orderBy('priority', 'asc')->take(1)->update(['slug' => 'it-alignment-keeping-ahead-of-change', 'session_type' => 'breakout', 'title' => 'IT Alignment - Keeping ahead of change', 'title_short' => 'IT Alignment', 'desc' => 'One of the most challenging tasks of the CIO is to ensure that the IT department is supporting and embracing the needs of the business.  With technology advancing rapidly, companies are being forced to change and adapt quickly in order to stay competitive within the industry.  How we handle these changes can have a deep impact on the bottom line for the organization.  Join our panel of experts as they discuss some of the things that they are doing to keep up with the demand for new technologies while embracing and supporting the needs of the business.']);
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->format('Y-m-d H:i:s'))->orderBy('priority', 'desc')->take(1)->update(['slug' => 'information-security', 'session_type' => 'session', 'title' => 'Information Security', 'title_short' => 'Information Security', 'desc' => 'Companies are collecting enormous amounts of real time information and data from customers, devices and employees.  There are many things that we can do to ensure that the information collected is protected and secure.  Join our panel as we discuss some of the challenges around:<ul><li>Adaptive Security Architectures – How they are used to identify and counter evolving threats</li><li>Email Security - protocol and enforcement of personal email through corporate mail systems</li><li>System ownership - ways to get end users and operators to take ownership of applications</li><li>End user security awareness training</li></ul>']);
     // 3:45 Keynote
     Agenda::where('conference_slug', '=', $slug)->where('timeslot', '=', $date->addHour()->addMinutes(15)->format('Y-m-d H:i:s'))->update(['slug' => 'the-value-of-it-solutions', 'session_type' => 'keynote', 'title' => 'The Value of IT Solutions', 'title_short' => 'The Value of IT Solutions', 'desc' => 'CIOs are continually asked to spend less and do more while supporting the needs of the organization.  In this session we will have an open dialogue on value of many IT solutions that companies use.  With newer and better technologies, software and upgrades always around the corner, looking at all of our options can save us a lot of time and money.  Join our panel of experts as they address pros and cons of subscription based vs. fully licensed products such as Office 365, flash storage vs. traditional storage and Cloud vs. private cloud or on premise solutions and the value of doing a short and long term cost benefit analysis before making a final decision.']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // SET PUBLISHED DATE
     $published = Carbon::now();
     // ADDING OPTIONS FOR 2016 AUSTIN CONFERENCE
     Option::insert(['slug' => '2016/austin', 'option' => 'show_topics', 'value' => 0, 'published' => $published]);
     Option::insert(['slug' => '2016/austin', 'option' => 'show_sponsors', 'value' => 1, 'published' => $published]);
 }
 protected function getOption($store_id, $order_id)
 {
     $option = Option::findOne(['store_id' => $store_id, 'name' => 'order_' . $order_id]);
     if (!$option) {
         throw new BadRequestHttpException("Order not found");
     }
     return $option;
 }
Ejemplo n.º 6
0
 /**
  * Get data status text view
  * @param integer $value
  * @return mixed
  */
 public function asDataStatus($value)
 {
     if ($value === null) {
         return $this->nullDisplay;
     }
     $options = Option::statusOptions();
     return isset($options[$value]) ? $options[$value] : $this->nullDisplay;
 }
Ejemplo n.º 7
0
 public function removeCorp(Request $request, $id)
 {
     if ($request->_action != 'remove_corp') {
         return back()->withErrors(['error' => 'Wrong action!']);
     }
     $option = Option::findOrFail($id);
     $option->delete();
     return back();
 }
Ejemplo n.º 8
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function index(Request $request)
 {
     $email = Option::where('key', 'contact.email')->first()->value;
     $phone = Option::where('key', 'contact.phone')->first()->value;
     $slogan = Option::where('key', 'site.slogan')->first()->value;
     $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value);
     $data = array('services' => Service::orderBy('sort_order')->get(), 'clients' => Client::orderBy('sort_order')->get(), 'photos' => Photo::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'slogan' => $slogan, 'social_links' => $social_links);
     return view('home', $data);
 }
Ejemplo n.º 9
0
 public function getOptionsByName()
 {
     $options_by_name = [];
     $options = Option::findAll(['store_id' => $this->id]);
     foreach ($options as $option) {
         $options_by_name[$option->name] = $option;
     }
     return $options_by_name;
 }
Ejemplo n.º 10
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function index(Request $request)
 {
     $email = Option::where('key', 'contact.email')->first()->value;
     $phone = Option::where('key', 'contact.phone')->first()->value;
     $company_data = array('name' => Option::where('key', 'company.name')->first()->value, 'address' => nl2br(Option::where('key', 'company.address')->first()->value), 'legal_left' => nl2br(Option::where('key', 'company.legal.left')->first()->value), 'legal_right' => nl2br(Option::where('key', 'company.legal.right')->first()->value));
     $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value);
     $data = array('photos' => Photo::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'social_links' => $social_links, 'company_data' => $company_data);
     return view('contact', $data);
 }
Ejemplo n.º 11
0
 public function saveOptions()
 {
     if ($this->store->id) {
         $options = $this->store->getOptionsByName();
         foreach ($this->attributes() as $attribute) {
             if (!empty($options[$attribute])) {
                 $option = $options[$attribute];
             } else {
                 $option = new Option();
                 $option->name = $attribute;
                 $option->link('store', $this->store);
             }
             $option->value = $this->{$attribute};
             $option->save();
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 12
0
 /**
  * 修改option数据表
  * @param string $type
  * @return integer 影响的行数
  */
 public function replace($type)
 {
     $row = 0;
     foreach ($this->attributes as $name => $value) {
         if ($this->getOldAttribute($name) == $value) {
             continue;
         }
         $row += Yii::$app->db->createCommand("REPLACE INTO " . Option::tableName() . " (type, name, value) VALUES(:type,:name,:value)", [':type' => $type, ':name' => $name, ':value' => $value])->execute();
     }
     return $row;
 }
Ejemplo n.º 13
0
 public function __construct(Route $route)
 {
     $this->middleware(function ($request, $next) {
         // if session is not set get it from .env SHOP_CODE
         if (!$request->session()->has('shop')) {
             $shop = Shop::where('code', config('app.shop_code'))->first();
             $request->session()->put('shop', $shop->id);
         }
         // if limit is not set default pagination limit
         if (!$request->session()->has('limit')) {
             $request->session()->put('limit', 102);
         }
         // if session is not set reset the session for the language
         if (!$request->session()->has('language')) {
             $request->session()->put('language', config('app.locale'));
         }
         // if session is not set reset the session for the currency
         if (!$request->session()->has('currency')) {
             $request->session()->put('currency', config('app.currency'));
         }
         if (!$request->session()->has('currency_rate')) {
             $currency = Currency::where('currency', config('app.currency'))->first();
             $request->session()->put('currency_rate', $currency->rate);
         }
         // if session is not set reset the session for the basket
         if (!$request->session()->has('basket')) {
             $request->session()->put('basket', ['subtotal' => 0, 'count' => 0, 'items' => []]);
         }
         // global list of categories
         if (!$request->session()->has('categories')) {
             $categories = Category::where('shop_id', $request->session()->get('shop'))->orderBy('order', 'asc')->get()->toArray();
             $request->session()->put('categories', $categories);
         }
         // global list of product filters
         if (!$request->session()->has('filters')) {
             $options = Option::all()->toArray();
             // Serialization of 'MongoDB\BSON\ObjectID' is not allowed
             $request->session()->put('filters', $options);
         }
         // share globals
         view()->share('language', $request->session()->get('language'));
         return $next($request);
     });
     // add controller & action to the body class
     $currentAction = $route->getActionName();
     list($controller, $method) = explode('@', $currentAction);
     $controller = preg_replace('/.*\\\\/', '', $controller);
     $action = preg_replace('/.*\\\\/', '', $method);
     view()->share('body_class', $controller . '-' . $action);
 }
Ejemplo n.º 14
0
 public function store(QuestionRequest $request)
 {
     $q = Question::create($request->all());
     $correct_answer_id;
     foreach ($request['options'] as $option) {
         $o = Option::create(['option' => $option['option'], 'question_id' => $q->id]);
         if ($request['correct_answer_id'] == $option['id']) {
             $correct_answer_id = $o->id;
         }
     }
     if ($request['correct_answer_id']) {
         CorrectAnswer::create(['question_id' => $q->id, 'option_id' => $correct_answer_id]);
     }
     return $q->toJson();
 }
Ejemplo n.º 15
0
 public static function options($route, $slug = null, $event = null)
 {
     $general = Option::where('slug', '=', 'general')->where('published', '>', '0000-00-00 00:00:00')->get();
     $page = Option::where('slug', '=', $route->action)->where('published', '>', '0000-00-00 00:00:00')->get();
     $general = self::keysByField($general, 'option');
     $page = self::keysByField($page, 'option');
     foreach ($general as $option => $values) {
         $options[$option] = $values->value;
     }
     foreach ($page as $option => $values) {
         $options[$option] = $values->value;
     }
     if (count($route->params) > 0 && $route->action === 'conference' && is_string($route->params['conference']) && is_string($route->params['year'])) {
         $slug = $route->params['year'] . '/' . $route->params['conference'];
     } elseif (is_object($event) || is_array($event)) {
         $event = (array) $event;
         $year = date('Y', strtotime($event['startdate']));
         $conference = $event['slug'];
         $slug = $year . '/' . $conference;
     }
     if (is_string($slug)) {
         $slug = Option::where('slug', '=', $slug)->where('published', '>', '0000-00-00 00:00:00')->get();
         $slug = self::keysByField($slug, 'option');
         foreach ($slug as $option => $values) {
             $options[$option] = $values->value;
         }
     }
     if (is_object($event)) {
         $event = (array) $event;
     }
     if (is_array($event)) {
         foreach ($options as $option => $value) {
             if (preg_match("/[a-z]+\\:[a-z]+/i", $value)) {
                 list($key, $val) = explode(':', $value);
                 if (isset($event[$val])) {
                     $obj = (object) $event[$val];
                     if (!empty($obj->scalar)) {
                         $options[$option] = $obj->scalar;
                     }
                 }
             }
         }
     }
     //		dd((object)$options);
     return (object) $options;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     Schema::create('options', function (Blueprint $table) {
         $table->increments('id');
         $table->string('option');
         $table->text('value');
         $table->tinyInteger('serialized')->default(0);
         $table->timestamps();
         $table->timestamp('published')->nullable();
         $table->softDeletes();
     });
     Option::create(['option' => 'maintenance', 'value' => '0', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
     Option::create(['option' => 'hero', 'value' => '0', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
     Option::create(['option' => 'active', 'value' => 'home', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
     Option::create(['option' => 'title', 'value' => 'Acclaim Events', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
     Option::create(['option' => 'jumbotron', 'value' => '/images/networking.jpg', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // SET UP NEW CARBON DATES
     $_old = '2017/tampa';
     $_new = (object) ['slug' => '2017/tampa', 'published' => Carbon::create(2016, 03, 02, 16, 30, 00), 'start' => Carbon::create(2017, 03, 02, 07, 00, 00), 'end' => Carbon::create(2017, 03, 02, 16, 30, 00)];
     // RESCHEDULE CONFERENCE
     $conference = Conference::where('slug', '=', $_old)->update(['slug' => $_new->slug, 'start_date' => $_new->start, 'end_date' => $_new->end, 'published' => $_new->published]);
     // UPDATE OPTIONS
     $options = Option::insert(['slug' => '2017/tampa', 'option' => 'show_upcoming', 'value' => 0, 'published' => Carbon::now()]);
     // UPDATE AGENDA
     $agendas = Agenda::where('conference_slug', '=', $_old)->get();
     foreach ($agendas as $agenda) {
         $agenda->conference_slug = $_new->slug;
         $agenda->timeslot = $_new->start->format('Y-m-d') . ' ' . $agenda->timeslot->format('H:i:s');
         $agenda->save();
     }
     // UPDATE SPEAKERS
     $speakers = Speaker::where('conference_slug', '=', $_old)->update(['conference_slug' => $_new->slug]);
 }
Ejemplo n.º 18
0
 /**
  * 获取Option信息
  * @param string $type 类型 默认为sys
  * @param bool $refresh 强制刷新
  * @return array $config 配置数组
  */
 public static function getSiteConfig($type = 'sys', $refresh = false)
 {
     $cache_key = "config_{$type}";
     if ($refresh) {
         $config = null;
     } else {
         $config = Yii::$app->cache->get($cache_key);
     }
     if (empty($config)) {
         $options = Option::find()->where(['type' => $type])->asArray()->all();
         foreach ($options as $op) {
             $config[$op['name']] = $op['value'];
         }
         $dp = new DbDependency();
         $dp->sql = (new Query())->select('MAX(update_time)')->from(Option::tableName())->createCommand()->rawSql;
         Yii::$app->cache->set($cache_key, $config, 3600, $dp);
     }
     return $config;
 }
Ejemplo n.º 19
0
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function index(Request $request)
 {
     $projects = Article::where('type', 'page')->orderBy('sort_order')->get();
     foreach ($projects as $project) {
         $services = explode(',', $project->services);
         $services_list = '<ul>';
         foreach ($services as $service) {
             $services_list .= '<li>' . $service . '</li>';
         }
         $services_list .= '</ul>';
         $project->services = $services_list;
         $project->logos = ProjectLogo::where('article_id', $project->id)->get();
         $project->images = ProjectImage::where('article_id', $project->id)->get();
     }
     $email = Option::where('key', 'contact.email')->first()->value;
     $phone = Option::where('key', 'contact.phone')->first()->value;
     $data = array('projects' => $projects, 'email' => $email, 'phone' => $phone);
     return view('portfolio', $data);
 }
Ejemplo n.º 20
0
 public function callback(Request $request)
 {
     $auth = 'Authorization: Basic ' . base64_encode(config('eve_sso.client_id') . ':' . config('eve_sso.client_secret'));
     $fields = ['grant_type' => 'authorization_code', 'code' => $request->input('code')];
     $uri = urldecode(http_build_query($fields));
     $client = new Client();
     $response = $client->request('POST', config('eve_sso.url_token'), ['auth' => [config('eve_sso.client_id'), config('eve_sso.client_secret')], 'allow_redirects' => true, 'form_params' => $fields]);
     $body = $response->getBody();
     $data = json_decode($body->getContents());
     //get character data
     $header = ['Authorization' => 'Bearer ' . $data->access_token];
     $response = $client->request('GET', config('eve_sso.url_verify'), ['headers' => $header]);
     $body = $response->getBody();
     $character = json_decode($body->getContents());
     $xml_api_url = 'https://api.eveonline.com/eve/CharacterAffiliation.xml.aspx?ids=' . $character->CharacterID;
     $response = $client->request('GET', $xml_api_url);
     $xml = simplexml_load_string($response->getBody()->getContents());
     if (!isset($xml->result->rowset->row->attributes()["characterID"])) {
         return redirect()->route('home')->withErrors(['login' => 'Character not valid.']);
     }
     $corp_id = (string) $xml->result->rowset->row->attributes()["corporationID"];
     $allianz_id = (string) $xml->result->rowset->row->attributes()["allianceID"];
     $option = Option::where('key', 'allowed_corps')->where('value', $corp_id)->first();
     $admin = false;
     if ($character->CharacterID == env('LOOTSHEET_ADMIN_ID')) {
         $admin = true;
     }
     if (!$option && !$admin) {
         return redirect()->route('home')->withErrors(['login' => 'Your Corporation is not allowed to use this lootsheet!']);
     }
     $user = User::firstOrCreate(['character_id' => $character->CharacterID]);
     $user->character_id = $character->CharacterID;
     $user->name = $character->CharacterName;
     $user->corp_id = $corp_id;
     $user->allianz_id = $allianz_id;
     $user->character_owner_hash = $character->CharacterOwnerHash;
     $user->admin = $admin;
     $user->save();
     Auth::login($user);
     return redirect()->route('home');
 }
Ejemplo n.º 21
0
 public static function lookup_options($params, $flags)
 {
     $options = (object) [];
     $lookup = Option::where('slug', '=', 'general')->get()->toArray();
     $general = Option::where('slug', '=', 'conference')->get()->toArray();
     if (!empty($params['slug'])) {
         $specific = Option::where('slug', '=', $params['slug'])->get()->toArray();
     }
     foreach ($lookup as $option) {
         $options->{$option}['option'] = $option['value'];
     }
     foreach ($general as $option) {
         $options->{$option}['option'] = $option['value'];
     }
     if (!empty($params['slug'])) {
         foreach ($specific as $option) {
             $options->{$option}['option'] = $option['value'];
         }
     }
     return $options;
 }
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //
        $published = Carbon::now();
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '=', 1)->update(['title' => 'Staffing, Training &amp; Talent Retention', 'text' => '<ul>
	<li>- How to recruit and retrain technical staff</li>
	<li>- IT Talent and Training
		<ul>
			<li>Supply and demand of IT talent - how to attract new talent</li>
			<li>The need for more online and virtual IT training</li>
			<li>When to hire and what to look for in a Security Officer</li>
		</ul>
	</li>
	<li>- Talent Retention - Culture and challenges of keeping top talent from leaving</li>
</ul>', 'published' => $published]);
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '=', 2)->update(['title' => 'Cyber Security', 'text' => '<ul>
	<li>- BYOD vs Corporate provided devices</li>
	<li>- Multi factor authentication and protecting mobile devices</li>
	<li>- How has web based application changed this paradigm</li>
</ul>', 'published' => $published]);
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '=', 3)->update(['title' => 'The Value of IT Solutions', 'text' => '<ul>
	<li>- Office 365</li>
	<li>- Flash Storage</li>
	<li>- Cloud vs on premise</li>
</ul>', 'published' => $published]);
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '=', 4)->update(['title' => 'Information Security', 'text' => '<ul>
	<li>- Adaptive security architecture to identify and counter evolving threats</li>
	<li>- Email Security - protocol and enforcement of personal email through corporate mail system</li>
	<li>- System ownership - the psychology of getting end users and operators to take ownership of applications</li>
	<li>- End user security awareness training</li>
</ul>', 'published' => $published]);
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '=', 5)->update(['title' => 'Internet of Things', 'text' => '- The effect on businesses of devices being added to the corporate network infrastructure', 'published' => $published]);
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '=', 6)->update(['title' => 'New Technology Trends', 'text' => '- This session will focus on new technologies that we can expect to see on the horizon', 'published' => $published]);
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '=', 7)->update(['title' => 'Business Continuity Disaster Recovery', 'text' => '<ul>
	<li>- Mitigating risk using cloud vs traditional brick and mortar</li>
	<li>- Resiliency - RPO and RTO, what are stated, tested and recoverable Standards</li>
</ul>', 'published' => $published]);
        Topic::where('conference_slug', '=', '2016/austin')->where('priority', '>', 7)->update(['published' => null]);
        Option::where('slug', '=', '2016/austin')->where('option', '=', 'show_topics')->update(['value' => 1, 'published' => $published]);
    }
Ejemplo n.º 23
0
 public function destroy(Question $question, Option $option)
 {
     $option->delete();
 }
Ejemplo n.º 24
0
 public function delete_questionset($id)
 {
     if (Auth::user()->type == 'teacher') {
         $questionset = Questionset::where(['id' => $id])->first();
         if ($questionset->type == 'descriptive') {
             if (count($questionset->descriptivequestions) != 0) {
                 foreach ($questionset->descriptivequestions as $descriptivequestion) {
                     DescriptiveQuestion::where(['id' => $descriptivequestion->id])->delete();
                 }
             }
         } else {
             if (count($questionset->multiplequestions) != 0) {
                 foreach ($questionset->multiplequestions as $multiplequestion) {
                     if (count($multiplequestion->options) != 0) {
                         foreach ($multiplequestion->options as $option) {
                             Option::where(['id' => $option->id])->delete();
                         }
                     }
                     MultipleQuestion::where(['id' => $multiplequestion->id])->delete();
                 }
             }
         }
         Questionset::where(['id' => $id])->delete();
         $questionsets = Questionset::where(['memberid' => Auth::user()->memberid])->get();
         $questionsetleft = Auth::user()->teacherinfo->packageinfo->questions - count($questionsets->all());
         return response()->json(['status' => 'success', 'message' => 'successfully deleted questionset', 'questionsetleft' => $questionsetleft]);
     } else {
         return 'not found link';
     }
 }
Ejemplo n.º 25
0
 /**
  * Show Product.
  *
  * @return Response
  */
 public function show(Request $request, $slug)
 {
     $product = Product::where('slug', $slug)->first();
     // product options
     if ($product->options) {
         $product->options = Option::whereIn('_id', $product->options)->get();
         if ($product->option_values) {
             $first = $product->option_values;
             $product->first = reset($first);
         }
     }
     // load only available options based on selected
     $available = [];
     if ($product->option_values) {
         foreach ($product->option_values as $option) {
             foreach ($option['options'] as $key => $opt) {
                 $available[$key][$opt] = [];
                 //$this->available($product, $key, $opt) ;
             }
         }
     }
     // product images
     $file_size = key(array_reverse(config('image.image_sizes')));
     //smallest
     $product->files = $this->getFiles('images/products/' . $product->id . '/' . $file_size);
     return view('themes/kudos/products/show', ['product' => $product, 'available' => $available]);
 }
Ejemplo n.º 26
0
 /**
  * Get option value.
  *
  * @return mixed
  */
 private function getOptionValueByKey($key)
 {
     $value = Option::item($key)->value;
     return $value;
 }
Ejemplo n.º 27
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     set_time_limit(0);
     ignore_user_abort(1);
     $english = Faker\Factory::create('en_GB');
     $french = Faker\Factory::create('fr_FR');
     $chinese = Faker\Factory::create('zh_CN');
     $german = Faker\Factory::create('de_DE');
     $spanish = Faker\Factory::create('es_ES');
     $lorem = new Faker\Provider\Lorem($english);
     $langs = ['fr' => 'french', 'cn' => 'chinese', 'de' => 'german', 'es' => 'spanish', 'en' => 'english'];
     $shopId = $this->argument('shop');
     $categories = (int) $this->argument('categories') + 1;
     $products = (int) $this->argument('products') + 1;
     // create 3 sets of options for color,size & material
     $data = ['Color' => ['Red', 'Green', 'Blue', 'Orange', 'Purple', 'Yellow'], 'Material' => ['Canvas', 'Glossy', 'Matt'], 'Size' => ['Xlarge', 'Large', 'Medium', 'Small', 'Xsmall']];
     // build and create option
     foreach ($data as $key => $options) {
         $currentOptions = [];
         foreach ($langs as $lang => $label) {
             $currentOptions[$lang][$key] = $options;
         }
         $currentOptions['default'] = $currentOptions[$lang];
         $option = Option::create($currentOptions);
     }
     for ($i = 1; $i < $categories; $i++) {
         // create a category;
         $categoryProducts = [];
         $category = new Category();
         $category->shop_id = $shopId;
         $category->parent = 0;
         $category->slug = 'category-' . $i;
         $category->products = [];
         foreach ($langs as $code => $lang) {
             $data = ['name' => ${$lang}->name . ' ' . $i, 'content' => $lorem->sentence($nbWords = 6, $variableNbWords = true)];
             $category->{$code} = $data;
         }
         $category->default = $data;
         $category->save();
         // create products
         for ($x = 1; $x < $products; $x++) {
             // store
             $product = new Product();
             $product->shop_id = $shopId;
             $product->slug = 'product-' . $x . '-category-' . $i;
             $product->sku = 'product-' . $x . '-category-' . $i;
             $product->categories = [$category->id];
             $product->price = number_format(rand(50, 275), 2);
             $product->rrp = number_format($product->price * 1.2, 2);
             $product->salePrice = number_format($product->price * 0.8, 2);
             foreach ($langs as $code => $lang) {
                 $data = ['name' => ${$lang}->name, 'content' => $lorem->sentence($nbWords = 200, $variableNbWords = true), 'excerpt' => $lorem->sentence($nbWords = 50, $variableNbWords = true)];
                 $product->{$code} = $data;
             }
             $product->default = $data;
             // save the product
             $product->save();
             // register product with each new option
             $options = Option::all();
             $newOptions = $toadd = [];
             foreach ($options as $option) {
                 $optionProduct = OptionProduct::firstOrNew(['option_id' => $option->id]);
                 $optionProduct->option_id = $option->id;
                 $optionProduct_products = isset($optionProduct->products) ? $optionProduct->products : [];
                 array_push($optionProduct_products, $product->id);
                 $optionProduct->products = $optionProduct_products;
                 $optionProduct->save();
                 // register option with this product
                 $productOptions = isset($product->options) ? $product->options : [];
                 array_push($productOptions, $option->id);
                 $product->options = $productOptions;
                 $product->option_values = [];
                 $option_default = $option->default;
                 $toadd[$option->id] = reset($option_default);
                 $product->save();
             }
             // we have the options lets add to the product
             $combo = [];
             for ($z = 0; $z < 3; $z++) {
                 foreach ($toadd as $key => $value) {
                     $combo[$z][$key] = array_rand($value, 1);
                 }
             }
             $combo = array_map('unserialize', array_unique(array_map('serialize', $combo)));
             //$newOptions[$option->id][] = array_rand(reset($toadd), 1);
             $count = 0;
             foreach ($combo as $c) {
                 $productOptionValues = $product->option_values;
                 $new = ['sku' => $product->sku . '_' . $count++, 'price' => $product->price, 'options' => $c];
                 $productOptionValues[] = $new;
                 $product->option_values = $productOptionValues;
                 $product->save();
             }
             // add this option to OPV table for quick filtering
             $povs = $product->option_values;
             foreach ($povs as $pov) {
                 foreach ($pov['options'] as $keyz => $optionz) {
                     $opv = OptionProductValue::where('filter', $keyz . '-' . $optionz)->first();
                     if (!$opv) {
                         // insert first
                         OptionProductValue::create(['filter' => $keyz . '-' . $optionz, 'products' => [$product->id]]);
                     } else {
                         // add to list
                         $p = $opv->products;
                         array_push($p, $product->id);
                         $opv->products = array_unique($p);
                         $opv->save();
                     }
                 }
             }
             // add images
             $categoryProducts[] = $product->id;
             app('App\\Http\\Controllers\\Admin\\MediaController')->generateImages('products', $product->id, 'http://lorempixel.com/1600/900/');
             $product->defaultImage = 'images/products/' . $product->id . '/large/image' . $product->id . '.jpg';
             $product->save();
         }
         $category->products = $categoryProducts;
         $category->save();
     }
 }
Ejemplo n.º 28
0
            <?php 
echo $form->field($model, 'label');
?>

            <?php 
echo $form->field($model, 'description');
?>
        </div>

        <div class="entry">
            <?php 
echo $form->field($model, 'return_type')->dropDownList(Lookup::returnTypeOptions(), ['prompt' => '']);
?>

            <?php 
echo $form->field($model, 'enabled')->dropDownList(Option::booleanOptions(), ['prompt' => '']);
?>
        </div>

        <div class="form-group buttons">
            <?php 
echo Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']);
?>
            <?php 
echo Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']);
?>
        </div>

        <?php 
ActiveForm::end();
?>
Ejemplo n.º 29
0
 public function questions(Request $request)
 {
     // [1] validate the title and the CSV
     $messages = ['title.required' => 'El título es requerido', 'the-csv.required' => 'El archivo de excel es requerido', 'the-csv.mimetypes' => 'El archivo debe ser excel'];
     $this->validate($request, ['title' => 'bail|required|max:255', 'the-csv' => 'required|mimetypes:application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], $messages);
     // [2] save the quiz blueprint
     $user = Auth::user();
     $blueprint = new Blueprint();
     $blueprint->title = $request->input("title");
     $blueprint->user_id = $user->id;
     $blueprint->is_closed = 0;
     $blueprint->is_public = 0;
     $blueprint->is_visible = 0;
     $blueprint->type = "generated";
     $blueprint->save();
     // [3] add the questions
     $file = $request->file("the-csv");
     $temp = $file->getPathName();
     Excel::load($temp, function ($reader) use($blueprint) {
         $reader->each(function ($row) use($blueprint) {
             if (trim($row->pregunta) != "") {
                 $question = new Question();
                 //$options  = !empty($row->seccion) ? (int)$row->seccion : 1;
                 $question->blueprint_id = $blueprint->id;
                 $question->question = $row->pregunta;
                 $question->section_id = !empty($row->seccion) ? (int) $row->seccion : 1;
                 $type = strtr(strtolower($row->tipo), "áéíóú", "aeiou");
                 if (in_array($type, ['numero', 'numerico', 'numerica', 'cantidad', 'cifra'])) {
                     $question->type = "number";
                 } elseif ($type == "estado") {
                     $question->type = "location-a";
                 } elseif ($type == "municipio") {
                     $question->type = "location-b";
                 } elseif ($type == "localidad") {
                     $question->type = "location-c";
                 } elseif ($type == "multiple" || $type == "opcion multiple") {
                     $question->type = "multiple";
                 } elseif ($type == "multiple multiple" || $type == "multiple-multiple") {
                     $question->type = "multiple-multiple";
                 } else {
                     $question->type = "text";
                 }
                 $question->save();
                 if (!empty($row->opciones) && ($question->type == "multiple" || $question->type == "multiple-multiple")) {
                     $options = explode("|", $row->opciones);
                     for ($i = 0; $i < count($options); $i++) {
                         $option = new Option();
                         $option->question_id = $question->id;
                         $option->blueprint_id = $blueprint->id;
                         $option->description = $options[$i];
                         $option->value = $i + 1;
                         //$options[$i];//$i+1;
                         $option->name = uniqid();
                         $option->order_num = $i;
                         $option->save();
                     }
                     // for
                 }
                 // if
             }
         });
     })->first();
     $request->session()->flash('status', ['type' => 'create', 'name' => $blueprint->title]);
     return redirect("dashboard/encuestas");
 }
Ejemplo n.º 30
0
 public function count()
 {
     return Option::count();
 }