/** * Guess the assignment names. * * @param Migration $migration */ public function guess(Migration $migration) { /** * If we don't have any addon then * we can't automate anything. * * @var Addon $addon */ if (!($addon = $migration->getAddon())) { return; } $stream = $migration->getStream(); $stream = $this->streams->findBySlugAndNamespace(array_get($stream, 'slug'), array_get($stream, 'namespace')); if (!$stream) { return; } $locale = $this->config->get('app.fallback_locale'); $assignments = $migration->getAssignments(); foreach ($assignments as &$assignment) { foreach (['label', 'warning', 'instructions', 'placeholder'] as $key) { if (is_null(array_get($assignment, $locale . '.' . $key))) { $assignment = array_add($assignment, $locale . '.' . $key, $addon->getNamespace('field.' . array_get($assignment, 'field') . '.' . $key . '.' . $stream->getSlug())); } } } $migration->setAssignments($assignments); }
/** * Unfollow a user * * @param $userIdToUnfollow * @return Response */ public function destroy($userIdToUnfollow) { $input = array_add(Input::all(), 'userId', Auth::id()); $this->execute(UnfollowUserCommand::class, $input); Flash::success("You have now unfollowed this user."); return Redirect::back(); }
function stop() { $item = array_pop($this->stack); $time = $this->microtime($item['start']); $name = $item['name']; global $wpdb; $item['queries'] = $wpdb->queries; global $wp_object_cache; $cache_dirty_count = $this->_dirty_objects_count($wp_object_cache->dirty_objects); $cache_dirty_delta = $this->array_sub($cache_dirty_count, $item['cache_dirty_objects']); if (isset($this->profile[$name])) { $this->profile[$name]['time'] += $time; $this->profile[$name]['calls']++; $this->profile[$name]['cache_cold_hits'] += $wp_object_cache->cold_cache_hits - $item['cache_cold_hits']; $this->profile[$name]['cache_warm_hits'] += $wp_object_cache->warm_cache_hits - $item['cache_warm_hits']; $this->profile[$name]['cache_misses'] += $wp_object_cache->cache_misses - $item['cache_misses']; $this->profile[$name]['cache_dirty_objects'] = array_add($this->profile[$name]['cache_dirty_objects'], $cache_dirty_delta); $this->profile[$name]['actions'] = array_add($this->profile[$name]['actions'], $item['actions']); $this->profile[$name]['filters'] = array_add($this->profile[$name]['filters'], $item['filters']); $this->profile[$name]['queries'] = array_add($this->profile[$name]['queries'], $item['queries']); #$this->_query_summary($item['queries'], $this->profile[$name]['queries']); } else { $queries = array(); $this->_query_summary($item['queries'], $queries); $this->profile[$name] = array('time' => $time, 'calls' => 1, 'cache_cold_hits' => $wp_object_cache->cold_cache_hits - $item['cache_cold_hits'], 'cache_warm_hits' => $wp_object_cache->warm_cache_hits - $item['cache_warm_hits'], 'cache_misses' => $wp_object_cache->cache_misses - $item['cache_misses'], 'cache_dirty_objects' => $cache_dirty_delta, 'actions' => $item['actions'], 'filters' => $item['filters'], 'queries' => $queries); } if (!$this->stack) { remove_filter('all', array($this, 'log_filter')); } }
/** * Follow a user * * @param Request $request * @return Response */ public function store(Request $request) { $input = array_add($request->only('userToFollow'), 'user_id', Auth::id()); $this->followRepo->followUser($input); flash()->success(trans('messages.follow_title'), trans('messages.follow_body')); return back(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $photoParent = PhotoParent::create($request->except('images', 'q')); // getting all of the post data $files = Input::file('images'); $result = array(); $file_count = count($files); // start count how many uploaded $uploadcount = 0; foreach ($files as $key => $file) { // $rules = array('file' => 'required'); //'required|mimes:png,gif,jpeg,txt,pdf,doc' // $validator = Validator::make(array('file'=> $file), $rules); // if($validator->passes()){ $storage = \Storage::disk('public'); $destinationPath = 'froala/uploads'; $storage->makeDirectory($destinationPath); $filename = time() . $key . '.' . $file->getClientOriginalExtension(); $upload_success = $file->move($destinationPath, $filename); $file_array = array(); $file_array = array_collapse([$file_array, ['id' => $key + 1, 'name' => $filename]]); $result = array_add($result, $key, $file_array); $jsonresult = json_encode($result); //$files_ser = serialize($result); $photoParent->images = $jsonresult; $photoParent->save(); $uploadcount++; // } // endif } return redirect()->route('admin.photoParent.index'); }
/** * Run checker * * @return void */ public function run() { $json = []; $json = array_add($json, 'name', 'BackendSeo Checker'); $json = array_add($json, 'url', $this->url->url); $json = array_add($json, 'checking', []); $project = $this->url->project; $projectUrls = $project->urls()->where('id', '>', $this->url->id)->get(); if ($this->option['title-similar'] || $this->option['desc-similar']) { foreach ($projectUrls as $url) { $this->getErrorDescription($json, $url); } } if ($this->option['depth'] && $this->url->depth > 3) { $desc = 'The url depth in this url is more than 3. It\'s recommended that the depth no more than 3 layer.'; array_push($json['checking'], ['error' => 'warning', 'desc' => $desc]); } if (!is_dir(base_path($this->destination))) { mkdir(base_path($this->destination), 0777, true); // true for recursive create } $result = fopen(base_path($this->destination) . "resultBackendSEO.json", "w"); fwrite($result, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); fclose($result); }
/** * Allows users to submit a product review * * @param ReviewProductRequest $request * @param $productID * * @return \Illuminate\Http\RedirectResponse * */ public function store(ReviewProductRequest $request, $productID) { $data = array_add($request->all(), 'product_id', $productID); $this->data = $this->productReviews->add($data); $this->setSuccessMessage("Your review was saved"); return $this->handleRedirect($request); }
/** * Store a newly created resource in storage. * * @param FlyerRequest|Request $request * @return Response */ public function store(FlyerRequest $request) { $input = array_add($request->all(), 'user_id', Auth::id()); $flyer = Flyer::create($input); flash()->success('Success', 'your flyer has been created'); return Redirect::to(url('/' . $flyer->zip . '/' . $flyer->street)); }
public function getAll() { $businesses = Business::with(['orders.orderItems.product', 'orders.invoices', 'orders.customer'])->get(); $stock = 0; foreach ($businesses as $business) { if ($business->name == "Nhập hàng") { $inStock = 0; foreach ($business->orders as $order) { foreach ($order->orderItems as $orderItem) { $inStock += $orderItem->quantity * $orderItem->product->cost; } } } if ($business->name == "Xuất hàng") { $outStock = 0; foreach ($business->orders as $order) { foreach ($order->orderItems as $orderItem) { $outStock += $orderItem->quantity * $orderItem->product->cost; } } } } $stock = $inStock - $outStock; array_add($businesses, 'stock', $stock); return Response::json($businesses); }
/** * Show user information * * @param integer $id * @return json */ public function show($id) { $user = $this->user->findUser($id); $latestActivities = $this->user->getUserLatestActivities($id); $json = array_add($user, 'latest_activities', $latestActivities); return $json; }
public function add($name, $link) { if (!is_array($this->links)) { $this->links = array(); } $this->links = array_add($this->links, $name, $link); }
/** * Remove the specified resource from storage. * */ public function destroy($userIdToUnfollow) { $input = array_add(Input::get(), 'userId', Auth::id()); $this->execute(UnfollowUserCommand::class, $input); Flash::success('Du har nu avföljt användaren.'); return Redirect::back(); }
public function __construct() { /** * getting role permissions */ $this->auth = Auth::user(); if (Auth::check()) { $this->perms = get_role_permissions($this->auth, 'billing'); $this->perms = array_add($this->perms, count($this->perms), 'check'); $this->perms = array_add($this->perms, count($this->perms), 'pay'); $this->perms = ['except' => $this->perms]; } else { $this->perms = guest_role_permissions('billing'); $this->perms = array_add($this->perms, 0, 'pay'); $this->perms = array_add($this->perms, 1, 'check'); $this->perms = ['except' => $this->perms]; } //print_r(bcrypt($this->auth->password)); /** * Middlewares */ $this->middleware('auth', ['except' => ['show', 'check', 'pay']]); $this->middleware('role', $this->perms); $this->middleware('language'); }
public function toArray() { /** @var \Codex\Codex $this */ return ['projects' => $this->projects->getItems()->map(function (\Codex\Projects\Project $project) { return array_add($project->toArray(), 'refs', $project->refs->toArray()); }), 'menus' => $this->menus->toArray()]; }
/** * Bootstrap any application services. * * @return void */ public function boot() { // view()->composer('layouts.master', function ($view) { $sidebar = array(); $Count = DB::table('projects')->where('PJtype', 'NGS')->count(); $sidebar = array_add($sidebar, 'NGScount', $Count); $Count = DB::table('projects')->where('PJtype', 'NGS')->where('status', '!=', '結案')->count(); $sidebar = array_add($sidebar, 'NGScountNotClose', $Count); $Count = DB::table('projects')->where('PJtype', 'NGS')->where('status', '=', '結案')->count(); $sidebar = array_add($sidebar, 'NGScountClose', $Count); $Count = DB::table('issue')->count(); $sidebar = array_add($sidebar, 'IssueCount', $Count); $Count = DB::table('issue')->where('status', '=', '等待回覆')->count(); $sidebar = array_add($sidebar, 'IssueCountWait', $Count); $Count = DB::table('issue')->where('status', '=', '已回覆')->count(); $sidebar = array_add($sidebar, 'IssueCountReply', $Count); $Count = DB::table('issue')->where('status', '=', '已結案')->count(); $sidebar = array_add($sidebar, 'IssueCountClosed', $Count); $sidebar = (object) $sidebar; $userQuestions = 0; $userSendIssue = DB::table('issue')->where('user_id', '=', \Auth::id())->where('status', '!=', '已結案')->count(); $userQueueQuestions = DB::table('question')->where('status', '=', '等待回覆')->Where(function ($query) { $query->where('sendList', 'like', \Auth::id() . '|%')->orWhere('sendList', 'like', '%|' . \Auth::id() . '|%')->orWhere('sendList', 'like', '%|' . \Auth::id())->orWhere('sendList', '=', \Auth::id()); })->count(); $userQuestions = $userSendIssue + $userQueueQuestions; //dd($sidebar->NGScount); $view->with('sidebar', $sidebar)->with('userQuestions', $userQuestions)->with('userSendIssue', $userSendIssue)->with('userQueueQuestions', $userQueueQuestions); }); }
public function run() { //get the subtopic and youtube videoids as array of key valur pair from config/subtopic.php //eg array('ETMA-101-1-1'=>array('fdfd','dffdf','sdsd')) $arrofsubtopicsandvideoid = Config::get('subtopic'); $arrofsubtopics = []; $i = 0; while ($i < sizeof($arrofsubtopicsandvideoid)) { //get the array of subtopics $arrofsubtopics = array_add($arrofsubtopics, $i, key($arrofsubtopicsandvideoid)); $i = $i + 1; next($arrofsubtopicsandvideoid); } //for each subtopic fetch all the videos from youtube for ($i = 0; $i < sizeof($arrofsubtopics); $i++) { $subtopic_code = $arrofsubtopics[$i]; $videoids = $arrofsubtopicsandvideoid[$subtopic_code]; //fetch all the videos title and description of a single subtopic and store in datbase for ($j = 0; $j < sizeof($videoids); $j++) { $client = new HttpClient(); $url = 'https://www.googleapis.com/youtube/v3/videos?id=' . $videoids[$j] . '&key=AIzaSyACqud0pby3FsKsbfHAUD17PSE7EBL7Yr0&part=snippet,contentDetails,statistics,status'; $response = $client->get($url); $m = $response->json(); $items = $m->items; $snippet = $items[0]->snippet; DB::table('videos')->insert(['subtopic_code' => $arrofsubtopics[$i], 'url' => 'https://www.youtube.com/watch?v=' . $videoids[$j] . '/', 'youtubevideoid' => $videoids[$j], 'title' => $snippet->title, 'description' => $snippet->description]); } } }
/** * @param $array * @param $key * @param $value * @return array */ public static function addQueryValue($array, $key, $value) { if (array_key_exists($key, $array)) { unset($array[$key]); } return array_add($array, $key, $value); }
/** * New status comment * * @param Request $request * @return Response */ public function store(Request $request) { $this->commentForm->validate($request->all()); $input = array_add($request->all(), 'user_id', Auth::id()); $this->statusRepo->leaveComment($input); return back(); }
public function postSchimbaStadiu($id_livrabil) { $actualizare_ore = Input::get('ore_lucrate') > 0; $is_stadiu = Input::get('stadiu_selectionat') != null && Input::get('stadiu_selectionat') > 0; $array_update = array(); if ($is_stadiu) { //Face insert in tabela de istoric de stadii //Actualizeaza stadiul livrabilului $array_update = array_add($array_update, 'id_stadiu', Input::get('stadiu_selectionat')); } if ($actualizare_ore) { //Actualizeaza numarul de ore lucrate la acest livrabil $array_update = array_add($array_update, 'ore_lucrate', Input::get('ore_lucrate')); } // Start transaction! DB::beginTransaction(); if ($is_stadiu) { try { DB::table('istoric_stadii_livrabil')->insertGetId(array('id_livrabil_etapa' => Input::get('id_livrabil_etapa'), 'id_stadiu' => Input::get('stadiu_selectionat'), 'id_user' => Entrust::user()->id)); } catch (Exception $e) { DB::rollback(); return Redirect::back()->with('message', 'Eroare salvare date: ' . $e); } } if ($is_stadiu || $actualizare_ore) { try { DB::table('livrabile_etapa')->where('id', Input::get('id_livrabil_etapa'))->update($array_update); } catch (Exception $e) { DB::rollback(); return Redirect::back()->with('message', 'Eroare salvare date: ' . $e); } } DB::commit(); return Redirect::back()->with('message', 'Actualizare realizata cu succes!')->withInput(); }
public function __construct(array $attributes = []) { $this->attributes['status'] = true; static::$rules = array_add(static::$rules, 'name', 'required|max:255'); static::$rules = array_add(static::$rules, 'price', 'required|numeric|min:0'); parent::__construct($attributes); }
public function AddOrder($array, $sumOrder) { // Добавляем к входящему массиву с данными о покупателе сумму заказа $array = array_add($array, 'sum_order', $sumOrder); //Записываем в таблицу и возвращаем id новой записи return $this->insertGetId($array); }
/** * Unfallow a User * * @param $userIdToUnfallow * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function destroy($userIdToUnfallow, Request $request) { $request->replace(array_add($request->all(), 'userId', Auth::id())); $this->dispatcher->dispatchFrom(UnfallowUser::class, $request); Flash::success('You have now unfallowed this user'); return Redirect::back(); }
public function create(array $data) { try { \DB::beginTransaction(); $teacherTraitData = array(); $teacherTraitData['grade'] = $data['grade']; $teacherTrait = $this->teacherTraitRepo->create($teacherTraitData); $data = array_add($data, 'traits_id', $teacherTrait->id); $schoolData = array_only($data, ['school', 'zipcode']); if (App::environment('local')) { $password = '******'; } else { $password = str_random(16); } $activated = 1; $data['password'] = $password; $data['activated'] = $activated; $teacherData = array_only($data, ['first_name', 'last_name', 'email', 'title', 'traits_id', 'password', 'activated']); $teacher = $this->teacherRepo->create($teacherData); $school = $this->schoolRepo->findOrCreate($schoolData); $teacher->schools()->attach($school->id); \Event::fire('user.created', [$teacher, $password]); \DB::commit(); return true; } catch (\Exception $ex) { \Log::error($ex); \DB::rollback(); return false; } }
/** * 自定义验证规则rules * * @return array */ public function rules() { $rules = ['title' => 'required|max:80', 'content' => 'required|min:20', 'thumb' => 'self_url']; $id = $this->segment(3) ? ',' . $this->segment(3) : ''; $rules = array_add($rules, 'slug', 'required|max:20|eng_alpha_dash|unique:contents,slug' . $id); return $rules; }
public function render() { $this->loadFiles(); $args = $this->arguments; $seq = $this->seq(); // set default file upload options $fileuploadOptions = ['previewMaxWidth' => 280, 'previewMaxHeight' => 120, 'previewCrop' => false, 'autoUpload' => false, 'acceptFileTypes' => "(\\.|\\/)(.*)\$", 'maxFileSize' => 5000000, 'replaceFileInput' => false, 'disableImageResize' => true, 'imageCrop' => false, 'imageMaxWidth' => 480, 'imageMaxHeight' => 240]; // set file if (isset($args['file'])) { $file = File::find($args['file']); if ($file === null) { unset($args['file']); } else { $filename = $file->clientname; $args['file'] = $filename; } } // resolve arguments $fileuploadOptions = array_merge($fileuploadOptions, array_get($args, 'fileuploadOptions', [])); $args = array_add($args, 'width', 420); $args = array_add($args, 'height', 240); array_set($fileuploadOptions, 'previewMaxWidth', $args['width']); array_set($fileuploadOptions, 'previewMaxHeight', $args['height']); $types = array_get($args, 'types'); if ($types !== null) { array_set($fileuploadOptions, 'acceptFileTypes', '(\\.|\\/)(' . implode('|', (array) $types) . ')$'); } array_set($args, 'fileuploadOptions', $fileuploadOptions); // render template $this->template = \View::make($this->view, ['args' => $args, 'seq' => $seq])->render(); return parent::render(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $instrumentos = Instrumento::with('tags')->ofNOmbre($request->nombre)->ofTags($request->tags)->ofPrestamo($request->prestamo)->ofEstado($request->estado)->paginate(12); $tags = Tag::lists('nombre', 'id'); $usuarios = array_add(User::lists('name', 'id'), '', ''); return view('instrumentos.index', compact('instrumentos', 'tags', 'usuarios')); }
public static function lista_padres($option) { if ($option == 1) { $categorias = categorias::orderBy('level')->select('categoria', 'id', 'level')->get(); $lista_categorias = array(); foreach ($categorias as $categoria) { $n = $categoria->level; $whole = floor($n); $fraction = $n - $whole; if (!$fraction > 0) { $lista_categorias = array_add($lista_categorias, $categoria->id, $categoria->categoria); } } } else { $categorias = categorias::orderBy('level')->select('categoria', 'id', 'level')->get(); foreach ($categorias as $categoria) { $n = $categoria->level; $whole = floor($n); $fraction = $n - $whole; if (!$fraction > 0) { $lista_categorias[] = '<option value="' . $categoria->id . '">' . $categoria->categoria . '</option>'; } } } return $lista_categorias; }
public function createRegistro() { $usuario = $this->usuariosRepo->newUsuario(); $token = md5(Input::only('email')['email'] . 'tokenmicai'); $usuario->token = $token; $this->data = Input::all(); // 1 -> Vendedor de la Foraneos/Nacionales/Extranjeros // 3 -> Vendedor de la UNACH switch ($this->data['tipo_procedencia']) { case 'ittg': $this->data['institucion_procedencia'] = 'Instituto Tecnologico de Tuxtla Gutierrez'; break; case 'unach': $this->data['vendedor'] = 4; $this->data['institucion_procedencia'] = 'Universidad Autonoma de Chiapas'; break; default: $this->data['vendedor'] = 3; break; } $manager = new RegistroManejador($usuario, $this->data); $this->data = array_add($this->data, 'token', $token); if ($manager->save()) { //Email de confirmacion Mail::send('emails/confirmationEmail', $this->data, function ($message) { $message->subject('Correo de confirmación'); $message->from('*****@*****.**', 'MICAI'); $message->to($this->data['email']); }); Session::flash('aviso', 'Usuario registrado corréctamente. Para continuar con tu registro activa tu cuenta desde tu correo'); return Redirect::route('inicio'); } return Redirect::back()->withInput()->withErrors($manager->getErrors()); }
public static function dailyBackgroundURL() { # get the number of day in the year $numberOfDayInYear = date('z'); # if there is backgrounds-production directory, go with that, otherwise go with backgrounds # (backgrounds-production is too large to be included in the git repository) $directory = '/img/backgrounds-production/'; if (!file_exists(public_path() . $directory)) { $directory = '/img/backgrounds/'; } # get the number of background images & collect them in an array $i = 0; $fileListArray = array(); $dir = public_path() . $directory; if ($handle = opendir($dir)) { while (($file = readdir($handle)) !== false) { if (!in_array($file, array('.', '..')) && !is_dir($dir . $file) && !(substr($file, 0, 1) === ".")) { $fileListArray = array_add($fileListArray, $i, $file); $i++; } } } $numberOfBackgroundFiles = $i; # calculate which image will we use $imageNumber = $numberOfDayInYear % $numberOfBackgroundFiles; # create the url that will be passed to the view $imageName = $fileListArray[$imageNumber]; $dailyBackgroundURL = $directory . $imageName; return $dailyBackgroundURL; }
public function show($id) { $brands = array_add($this->brandRepo->lists(), '', 'Seleccione Laboratorio'); $presentations = array_add($this->presentationRepo->lists(), '', 'Seleccione Presentación'); $order = $this->orderRepo->findOrFail($id); return view('orders/show', compact('order', 'brands', 'presentations')); }