Example #1
1
 public static function themeLists($target = null)
 {
     if ($target) {
         $items = static::where('target', '=', $target)->get();
         return array_pluck($items, 'name', 'id');
     }
 }
Example #2
0
 /**
  * Validate and attach selection models via deferred bindings
  *
  * @param  array $selections
  * @return void
  * @throws \October\Rain\Exception\ValidationException
  */
 public function bindSelections($selections)
 {
     $collection = new Collection();
     if (is_array($selections)) {
         // Translate our selections into a collection
         foreach ($selections['id'] as $i => $id) {
             $selection = $id ? Selection::findOrNew($id) : new Selection();
             $selection->sort_order = $i;
             $selection->name = trim($selections['name'][$i]);
             $selection->validate();
             $collection->push($selection);
         }
         // Ensure selections are unique
         $names = array_map('strtolower', array_pluck($collection->toArray(), 'name'));
         if (count($names) > count(array_unique($names))) {
             $message = Lang::get('bedard.shop::lang.selection.validation_unique');
             Flash::error($message);
             throw new ValidationException($message);
         }
     }
     // Require at least one selection
     if ($collection->count() === 0) {
         $message = Lang::get('bedard.shop::lang.option.selection_required');
         Flash::error($message);
         throw new ValidationException($message);
     }
     // Bind the collection to the option
     $this->bindEvent('model.afterSave', function () use($collection) {
         $this->saveSelections($collection);
     });
 }
Example #3
0
 /**
  * 获取未分配的模块列表
  * @param array $allModuleList
  * @return array
  */
 protected function uniqueModuleList(array $allModuleList)
 {
     $dbModuleList = AclModuleModel::all();
     //获取数据库中所有模块信息
     $dbModuleList = array_pluck($dbModuleList ? $dbModuleList->toArray() : [], 'ident');
     return array_diff($allModuleList, $dbModuleList);
 }
 public function quiz()
 {
     if (Session::has('id') && (Session::get('type') === 'Student' || Session::get('type') === 'SuperAdmin')) {
         //$questions = Question::all();
         //$ansAr = array(
         //);
         $random_question = Question::orderBY(DB::raw('Rand()', 'Unique()'))->take(2)->get(array('id', 'q_description', 'q_opt_1', 'q_opt_2', 'q_opt_3', 'q_opt_4', 'q_ans'));
         //print_r($random_question);
         $cnt = 0;
         foreach ($random_question as $tmp) {
             //			    print_r($tmp);
             //			    print("---------------\n-----------------");
             $cnt++;
         }
         $totNoOfQus = $cnt;
         //echo $cnt;
         $correct_answer = array_pluck($random_question, 'q_ans');
         $qIds = array_pluck($random_question, 'id');
         $combined = array_combine($qIds, $correct_answer);
         //		    echo '<pre>';
         //		    print_r($combined);
         //		    die;
         Session::put('correct_answer', $combined);
         Session::put('total_qus', $totNoOfQus);
         //		    return $correct_answer;
         return view::make('quiz')->with('title', 'QUIZ')->with('quiz', $random_question);
     } else {
         echo 'You are not authorised';
     }
 }
Example #5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (in_array('Admin', array_pluck(auth()->user()->roles->toArray(), 'name'))) {
         return $next($request);
     }
     return redirect('/home');
 }
Example #6
0
 /**
  * TwoSelectBox constructor.
  *
  * @param       $name
  * @param       $type
  * @param Form  $parent
  * @param array $options
  */
 public function __construct($name, $type, Form $parent, array $options)
 {
     $options['attr']['extend'] = true;
     $options['attr']['multiple'] = true;
     $options['btnSelect'] = array_merge(['class' => 'btn', 'id' => 'btnSelect'], isset($options['btnSelect']) ? $options['btnSelect'] : []);
     $options['btnUnSelect'] = array_merge(['class' => 'btn', 'id' => 'btnUnSelect'], isset($options['btnUnSelect']) ? $options['btnUnSelect'] : []);
     $options['container_id'] = Str::studly(Str::slug($name, '_')) . "TwoSelectBoxContainer";
     /** Load data from model */
     /** @var Model $model */
     $model = $options['model'];
     $primary = $options['primary'];
     $show = $options['show'];
     /** Detect I18N */
     $locale = \Config::get('app.locale');
     $is_i18n = method_exists($model, 'saveI18N');
     $query = $is_i18n ? $model::I18N($locale) : $model::query();
     /** END **/
     if (key_exists('filter', $options) && count($options['filter']) > 0) {
         foreach ($options['filter'] as $key => $item) {
             $query->where($key, $item['condition'], $item['value']);
         }
     }
     /** Parse to key-name format {$table}.{$field} */
     $keyName = strpos($options['primary'], '.') ? $options['primary'] : (new $model())->getTable() . "." . $options['primary'];
     $data = $query->select($keyName, $show)->get()->toArray();
     /** Fill model data to choice array */
     $options['choices'] = array_pluck($data, $show, $primary);
     /** END */
     $options['selected'] = array_get($options, 'value', []);
     /** END */
     $options['selected'] = (array) (isset($options['selected']) ? $options['selected'] : []);
     parent::__construct($name, $type, $parent, $options);
 }
Example #7
0
 /**
  * Handle the event.
  *
  * @param  ProjectWatcher  $event []
  * @return void
  */
 public function handle(ProjectWatcher $event)
 {
     $urlsFromDatabase = $event->project->urls->pluck('url');
     if (is_string($urlsFromDatabase)) {
         $urlsFromDatabase = (array) $urlsFromDatabase;
     } else {
         $urlsFromDatabase = $urlsFromDatabase->toArray();
     }
     $this->crawler->setBaseUrl($event->project->main_url);
     $this->crawler->start();
     $urlsFromWeb = array_merge($this->crawler->getSiteUrl(), $this->crawler->getSiteCss(), $this->crawler->getSiteJs());
     if (empty($urlsFromDatabase)) {
         foreach ($urlsFromWeb as $url) {
             $this->addNewUrl($event, $url);
         }
     } else {
         foreach ($urlsFromWeb as $url) {
             if (!in_array($url['url'], $urlsFromDatabase)) {
                 $this->addNewUrl($event, $url);
             }
         }
         foreach ($urlsFromDatabase as $url) {
             $objectUrl = Url::ByUrl($url)->first();
             if (!in_array($url, array_pluck($urlsFromWeb, 'url'))) {
                 $objectUrl->update(['is_active' => false]);
             } else {
                 $objectUrl->update(['is_active' => true]);
             }
         }
     }
     $event->project->update(['is_crawlable' => false]);
 }
Example #8
0
 public function dashboard()
 {
     $view = [];
     $days = 30;
     $view['days'] = $days;
     if (env('ANALYTICS_SITE_ID') == '') {
         return view("mixdinternet/admix::dashboard", $view);
     }
     $graph = [];
     $dataAnalytics = LaravelAnalytics::getVisitorsAndPageViews($days);
     $graph['visitors'] = implode(',', array_pluck($dataAnalytics, 'visitors'));
     $graph['pageViews'] = implode(',', array_pluck($dataAnalytics, 'pageViews'));
     $carbonDate = array_pluck($dataAnalytics, 'date');
     $date = [];
     foreach ($carbonDate as $carbon) {
         $date[] = $carbon->formatLocalized('%d/%m');
     }
     $graph['label'] = '"' . implode('","', $date) . '"';
     $view['graph'] = $graph;
     $view['direct'] = LaravelAnalytics::getTopReferrers($numberOfDays = $days, $maxResults = 10);
     $view['mostVisited'] = LaravelAnalytics::getMostVisitedPages($numberOfDays = $days, $maxResults = 10);
     $view['topBrowser'] = LaravelAnalytics::getTopBrowsers($numberOfDays = $days, $maxResults = 10);
     $view['topKeywords'] = LaravelAnalytics::getTopKeywords($numberOfDays = $days, $maxResults = 10);
     $dataAnalytics = LaravelAnalytics::performQuery(Carbon::now()->subDays($days), Carbon::now(), 'ga:pageviews');
     $box['pageViews'] = $dataAnalytics['rows'][0][0];
     $dataAnalytics = LaravelAnalytics::performQuery(Carbon::now()->subDays($days), Carbon::now(), 'ga:uniquePageviews');
     $box['uniquePageviews'] = $dataAnalytics['rows'][0][0];
     $dataAnalytics = LaravelAnalytics::performQuery(Carbon::now()->subDays($days), Carbon::now(), 'ga:avgTimeOnPage');
     $box['avgTimeOnPage'] = Carbon::createFromTimestamp($dataAnalytics['rows'][0][0])->format('i:s');
     $dataAnalytics = LaravelAnalytics::performQuery(Carbon::now()->subDays($days), Carbon::now(), 'ga:bounceRate');
     $box['bounceRate'] = $dataAnalytics['rows'][0][0];
     $view['box'] = $box;
     return view("mixdinternet/admix::dashboard", $view);
 }
 public function make(array $data)
 {
     $otherSetting = $data['others'];
     $categoryType = array_get($otherSetting['setting'], 'category');
     $categoryLayer = config("module.category.layer.{$categoryType}");
     $attributes = $this->attributes($data);
     $categories = Categorize::getCategoryProvider()->root()->whereType($categoryType)->orderBy('sort', 'asc')->get();
     $option = Categorize::tree($categories)->lists('title', 'id');
     $form = '<select' . $attributes . '><option value="0">' . pick_trans('option.pleaseSelect') . '</option>';
     if ($categoryLayer === 2) {
         if (count($option)) {
             foreach ($option as $key => $value) {
                 $category = Categorize::getCategoryProvider()->whereType($categoryType)->whereTitle($value)->first()->getChildren()->toArray();
                 $optgroup = $this->getSelectOptgroup($category['title']);
                 if (isset($category['children']) && count($category['children']) > 0) {
                     $form .= sprintf($optgroup, $this->getSelectOption($data, array_pluck($category['children'], 'title', 'id')));
                 } else {
                     $form .= $optgroup;
                 }
             }
         }
     } else {
         $form .= $this->getSelectOption($data, $option);
     }
     $form .= '</select>';
     return $form;
 }
Example #10
0
 public function __construct($name, $type, Form $parent, array $options)
 {
     /** @var Model $model */
     $model = $options['model'];
     $primary = $options['primary'];
     $show = $options['show'];
     $none_selected_item = isset($options['none_selected_item']) ? $options['none_selected_item'] : true;
     /** Detect I18N */
     $locale = Session::get('cms.locale', \Config::get('app.locale', 'en'));
     $is_i18n = method_exists($model, 'saveI18N');
     $query = $is_i18n ? $model::I18N($locale) : $model::query();
     /** END **/
     if (key_exists('filter', $options) && count($options['filter']) > 0) {
         foreach ($options['filter'] as $key => $item) {
             $query->where($key, $item['condition'], $item['value']);
         }
     }
     /** Parse to key-name format {$table}.{$field} */
     $keyName = strpos($options['primary'], '.') ? $options['primary'] : (new $model())->getTable() . "." . $options['primary'];
     $data = $query->select($keyName, $show)->get()->toArray();
     /** Fill model data to choice array */
     $options['choices'] = [];
     if ($none_selected_item) {
         $options['choices'] = [null => ''];
     }
     $options['choices'] = $options['choices'] + array_pluck($data, $show, $primary);
     /** END */
     $options['selected'] = array_get($options, 'value', null);
     parent::__construct($name, $type, $parent, $options);
 }
Example #11
0
 public function __construct($upload_id)
 {
     parent::__construct('commercialauditing', $upload_id);
     $regions = Config::get('plr.frontend.filter_order.commercial-auditing.region');
     $regions = array_pluck($regions, 'dbLabel');
     $this->string('country')->position(0);
     $this->string('reference')->position(1)->insert();
     $this->string('company')->position(2)->insert();
     $this->string('brand')->position(3)->insert();
     $this->string('product')->position(4)->insert();
     $this->integer('spots')->position(5)->insert();
     $this->seconds('airtime')->position(6)->insert();
     $this->enum('region', $regions)->position(7);
     $this->string('channel')->position(8);
     $this->string('season')->position(9);
     $this->integer('productcategory_id')->insert();
     $this->integer('territory_id')->insert();
     $this->integer('channel_id')->insert();
     $this->integer('upload_id')->insert();
     $this->integer('season_id')->insert();
     $this->datetime('created_at', 'Y-m-d H:i:s')->insert();
     $this->datetime('updated_at', 'Y-m-d H:i:s')->insert();
     $this->relation('productcategories', 'productcategory_id')->field('name', 'product')->onBeforeInsert([$this, 'makeTimestamps']);
     $this->relation('territories', 'territory_id')->field('name', 'country')->field('region', 'region')->onBeforeInsert([$this, 'makeAbb'])->onBeforeInsert([$this, 'makeTimestamps']);
     $this->relation('channels', 'channel_id')->field('name', 'channel')->onBeforeInsert([$this, 'addUploadId'])->onBeforeInsert([$this, 'makeAbb'])->onBeforeInsert([$this, 'makeTimestamps']);
     $this->relation('seasons', 'season_id')->field('name', 'season')->onBeforeInsert([$this, 'makeTimestamps']);
     $this->on('parsed', [$this, 'makeTimestamps']);
 }
Example #12
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = $this->user->getById($id);
     $roles = $this->role->getAll();
     $user_roles = array_pluck($user->roles, 'id');
     return view('admin/users/edit', compact('user', 'roles', 'user_roles'));
 }
Example #13
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $role = $this->role->getById($id);
     $permissions = $this->perm->getAll();
     $role_permissions = array_pluck($role->perms, 'id');
     return view('admin/roles/edit', compact('role', 'permissions', 'role_permissions'));
 }
Example #14
0
 /**
  * Store a newly created resource in storage.
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $order = new OrderDelay();
     $order->fill($request->only('reason'));
     $order->student_id = $this->student->id;
     $order->academystructure_department_id = $this->student->academystructure_department_id;
     $order->semester_id = $this->semester->id;
     $order->state = 'تقديم';
     $order->save();
     // create order history record
     $history = new Orderhistory();
     $history->ref_key = 'order_delays';
     $history->ref_value = $order->id;
     $history->state = 'تقديم';
     $history->save();
     // check if financial item active then create debit record
     $invoice_item = FinancialInvoiceItem::where('slug', 'delayed_fee')->where('state', 'نشط')->first();
     if ($invoice_item) {
         $invoice_data = ['ref_key' => 'order_delays', 'ref_value' => $order->id, 'student_id' => $this->student->id, 'amount' => $invoice_item->amount, 'type' => 'debit', 'semester_id' => $this->semester->id, 'item_id' => $invoice_item->id, 'note' => 'تكلفة طلب تاجيل دراسة'];
         FinancialInvoice::create($invoice_data);
     }
     if ($request->has('files')) {
         OrderFile::whereIn('id', array_pluck($request->input('files'), 'id'))->update(['ref_value' => $order->id, 'ref_key' => 'order_delays']);
     }
     $order->load('files');
     return response()->json($order, 200, [], JSON_NUMERIC_CHECK);
 }
Example #15
0
 public function testEndScope()
 {
     $before = array_pluck($this->test->get()->toArray(), 'item');
     $this->assertContains('Another', $before);
     $after = array_pluck($this->test->notEndingWith('her')->get()->toArray(), 'item');
     $this->assertNotContains('Another', $after);
 }
Example #16
0
 /**
  * Prepares the view data
  */
 protected function prepareVars()
 {
     $fieldName = $this->formField->getName();
     if (substr($fieldName, -2) != '[]') {
         $fieldName .= '[]';
     }
     $this->vars['name'] = $fieldName;
     $value = $this->getLoadValue();
     // If it's a collection will return
     // the first fillable element
     if (is_a($value, Collection::class)) {
         if (!$value->isEmpty()) {
             $first = $value->first();
             $fillable = reset($first->fillable);
             $value = array_pluck($value->toArray(), $fillable);
         } else {
             $value = [];
         }
     }
     if (!is_array($value) and !is_null($value)) {
         throw new \Exception('Field ' . $this->fieldName . ' value must be null or an array.');
     }
     $this->vars['values'] = $value;
     $this->vars['field'] = $this->formField;
     $this->vars['placeholder'] = $this->placeholder;
     $this->vars['allowClear'] = $this->allowClear;
 }
 /**
  * Removes all local galleries for the current user list.
  *
  * @return Response
  */
 public function destroyList()
 {
     $users = Input::get('users');
     $userIds = array_pluck($users, 'id');
     $removed = $this->gallery->destroyByUsers($userIds);
     return Redirect::route('users.index')->with('message', "Has been removed {$removed} galleries");
 }
Example #18
0
 /**
  * Get all permission slugs from all permissions of all roles.
  *
  * @return array of permission slugs
  */
 protected function getAllPermissionsFormAllRoles()
 {
     $permissions = $this->roles->load('permissions')->pluck('permissions')->toArray();
     return array_map('strtolower', array_unique(array_flatten(array_map(function ($permission) {
         return array_pluck($permission, 'Pm_Slug');
     }, $permissions))));
 }
 private function syncColumns($tables)
 {
     $bar = $this->output->createProgressBar(count($tables));
     /** @var DbTable $table */
     foreach ($tables as $table) {
         $columnSql = "select t.table_schema as db_name,   \nt.table_name,   \n(case when t.table_type = 'BASE TABLE' then 'table' \nwhen t.table_type = 'VIEW' then 'view'  \nelse t.table_type   \nend) as table_type, \nc.column_name,  \nc.column_type,  \nc.column_default,   \nc.column_key,   \nc.is_nullable,  \nc.extra,    \nc.column_comment    \nfrom information_schema.tables as t \ninner join information_schema.columns as c  \non t.table_name = c.table_name  \nand t.table_schema = c.table_schema \nwhere t.table_type in('base table', 'view') \nand t.table_schema = '{$this->dbName}'\nand t.table_name = '{$table->name}'\norder by t.table_schema, t.table_name, c.ordinal_position";
         $columnInfos = DB::select($columnSql);
         foreach ($columnInfos as $columnInfo) {
             $columnBuilder = $table->columns()->withTrashed()->where('name', $columnInfo->column_name);
             if ($columnBuilder->exists()) {
                 $column = $columnBuilder->first();
                 if ($column->trashed()) {
                     $column->restore();
                 }
                 $table->columns()->where('name', $columnInfo->column_name)->update(['name' => $columnInfo->column_name, 'type' => $columnInfo->column_type, 'default' => $columnInfo->column_default, 'key' => $columnInfo->column_key, 'is_nullable' => $columnInfo->is_nullable == 'YES' ? true : false, 'extra' => $columnInfo->extra, 'comment' => $columnInfo->column_comment]);
             } else {
                 $table->columns()->create(['name' => $columnInfo->column_name, 'type' => $columnInfo->column_type, 'default' => $columnInfo->column_default, 'key' => $columnInfo->column_key, 'is_nullable' => $columnInfo->is_nullable == 'YES' ? true : false, 'extra' => $columnInfo->extra, 'comment' => $columnInfo->column_comment]);
             }
         }
         $columnNames = array_pluck($columnInfos, 'column_name');
         $table->columns()->whereNotIn('name', $columnNames)->delete();
         $bar->advance();
     }
     $bar->finish();
 }
Example #20
0
 public function listPackages()
 {
     $path = app_path() . '/Cms/Packages/Source/';
     $files = \FilesHelper::filesInFolder($path);
     $packages = array_pluck($files, 'name');
     return $packages;
 }
 public function getMovies(Request $request)
 {
     date_default_timezone_set('Europe/Moscow');
     if ($request->input('city_id') == null) {
         $city = $request->user()->city_id;
     } else {
         $city = $request->input('city_id');
     }
     $cities = Cities::orderBy('city')->get();
     $cityList = [];
     foreach ($cities as $key => $value) {
         $cityList[$value->id] = $value->city;
     }
     $cinemas = Cinemas::where("city_id", $city)->orderBy("title")->get();
     $cinemasIds = array_pluck($cinemas, "id");
     $seances = \App\Seances::whereIn("cinema_id", $cinemasIds)->where("start_time", '>', date("Y-m-d H:i:s"))->groupBy("movie_id")->with('getMovie')->get();
     $movies = [];
     foreach ($seances as $item) {
         $movie = $item->getMovie->getAttributes();
         $poster = json_decode($item->getMovie->poster)->name;
         $movie['poster'] = $poster;
         //Helper::getPosterLink($poster);
         $movies[] = $movie;
     }
     return view()->make('search.movies_filter', array('movies' => $movies, 'cityList' => $cityList, 'city' => $city));
 }
 public function run()
 {
     $admin = Role::where('name', '=', 'administrator')->first();
     $perms = Permission::all();
     $admin->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'users manager')->first();
     $perms = Permission::where('name', '=', 'manage_users')->orWhere('name', '=', 'delete_users')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'premium author')->first();
     $perms = Permission::where('name', '=', 'manage_premium_casts')->orWhere('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'author')->first();
     $perms = Permission::where('name', '=', 'manage_free_casts')->orWhere('name', '=', 'manage_series')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'eraser')->first();
     $perms = Permission::where('name', '=', 'delete_series')->orWhere('name', '=', 'delete_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'premium user')->first();
     $perms = Permission::where('name', '=', 'view_premium_casts')->orWhere('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'user')->first();
     $perms = Permission::where('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
     $man = Role::where('name', '=', 'guest')->first();
     $perms = Permission::where('name', '=', 'view_free_casts')->get();
     $man->perms()->sync(array_pluck($perms, 'id'));
 }
 /**
  * Execute the console command.
  *
  * @param Settings $settings
  * @return mixed
  */
 public function handle()
 {
     $client = new \Github\Client();
     if ($this->cache && config('game-of-tests.cache') && class_exists(CacheItemPool::class)) {
         $client->addCache(new CacheItemPool($this->cache));
     }
     $this->info('Getting repository list');
     if ($this->argument('organisation') !== false) {
         $repositories = $client->organization()->repositories($this->argument('organisation'), 'owner');
     }
     $repositoryUrls = array_pluck($repositories, 'clone_url');
     $this->info('Found ' . count($repositoryUrls) . ' repositories on Github');
     $progresbar = $this->output->createProgressBar(count($repositoryUrls));
     $progresbar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %message% ');
     $progresbar->setMessage('Searching...');
     \Swis\GotLaravel\Models\Results::unguard();
     $inspector = new Inspector($this->settings);
     foreach ($repositoryUrls as $gitUrl) {
         $repository = $inspector->getRepositoryByUrl($gitUrl);
         // Check modified date
         if (null !== $this->option('modified')) {
             $modifiedTimestamp = strtotime($this->option('modified'));
             /**
              * @var $date \DateTime
              */
             try {
                 $commitDate = $repository->getHeadCommit()->getCommitterDate();
             } catch (\Gitonomy\Git\Exception\ReferenceNotFoundException $e) {
                 $this->error($e->getMessage());
                 $this->error('Error finding reference for ' . $gitUrl);
             }
             if ($modifiedTimestamp === false || $commitDate->getTimestamp() < $modifiedTimestamp) {
                 $progresbar->advance();
                 continue;
             }
         }
         $repository->setLogger(new ConsoleLogger($this->getOutput()));
         $resultSet = $inspector->inspectRepository($repository);
         $remote = $resultSet['remote'];
         if (count($resultSet['results']) > 0) {
             $progresbar->setMessage('Found ' . count($resultSet['results']) . ' tests for ' . $remote);
         }
         if (!$this->option('dry-run')) {
             foreach ($resultSet['results'] as $result) {
                 $insert = $result->toArray();
                 $insert['remote'] = $remote;
                 $insert['author_slug'] = Str::slug($result->getAuthor());
                 $insert['created_at'] = Carbon::createFromTimestamp($insert['date']);
                 try {
                     \Swis\GotLaravel\Models\Results::updateOrCreate(array_only($insert, ['remote', 'filename', 'line']), $insert);
                 } catch (\Exception $e) {
                     $this->error('Couldnt insert: ' . $e->getMessage() . PHP_EOL . print_r($insert, 1));
                 }
             }
         }
         $progresbar->advance();
     }
     Artisan::call('got:normalize-names');
 }
Example #24
0
 public function getAvailability()
 {
     $result = $this->client->request('GET', '/api/crimes-street-dates');
     $items = json_decode($result->getBody(), true);
     $items = array_pluck($items, 'date');
     sort($items);
     return $items;
 }
Example #25
0
 public function uploadBandsByGenre($genre, $count = 100)
 {
     $responseJson = $this->httpService->sendGet($this->getArtistByStyleUrl($genre, $count))->getBody();
     $response = json_decode($responseJson, true);
     return array_map(function ($artist) {
         return ['name' => $artist['name'], 'data' => ['genres' => array_pluck($artist['genres'], 'name'), 'images' => array_pluck($artist['images'], 'url')]];
     }, $response['response']['artists']);
 }
Example #26
0
 public function getAllPermissionsFormAllRoles()
 {
     $permissionArray = [];
     $permission = $this->roles->load('permissions')->fetch('permissions')->toArray();
     return array_map('strtolower', array_unique(array_flatten(array_map(function ($permission) {
         return array_pluck($permission, 'permission_slug');
     }, $permission))));
 }
Example #27
0
 /**
  * Check if user has specific permission
  *
  * @param $permission
  * @return bool
  */
 public function can($permission)
 {
     $this->checkIfRelationToRoleExist();
     if (!$this->permissions) {
         $this->permissions = array_pluck($this->getPermissions(), 'tag');
     }
     return in_array($permission, $this->permissions);
 }
Example #28
0
 protected function createTrees(array $orders)
 {
     $trees = [];
     foreach ($orders as $serNo => $orderDiv) {
         $trees[] = new OrderNoTree($serNo, array_get($orderDiv, '0.' . self::ORDERNO_KEY), array_pluck($orderDiv, self::DIVNO_KEY));
     }
     return $trees;
 }
Example #29
0
 public function doesUserFollowThis($entity_id)
 {
     $followed = array_pluck($this->entities, 'id');
     if (in_array($entity_id, $followed)) {
         return true;
     }
     return false;
 }
Example #30
0
 public static function first_term_slug($query)
 {
     $termslug = $query->terms()->get()->toArray();
     if (!is_null($termslug)) {
         $termslug = array_pluck($termslug, 'slug');
         return $termslug[0];
     }
 }