本文整理汇总了PHP中array_add函数的典型用法代码示例。如果您正苦于以下问题:PHP array_add函数的具体用法?PHP array_add怎么用?PHP array_add使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_add函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guess
/**
* 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);
}
示例2: destroy
/**
* 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();
}
示例3: stop
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'));
}
}
示例4: store
/**
* 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();
}
示例5: store
/**
* 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');
}
示例6: run
/**
* 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);
}
示例7: store
/**
* 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);
}
示例8: store
/**
* 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));
}
示例9: getAll
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);
}
示例10: show
/**
* 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;
}
示例11: add
public function add($name, $link)
{
if (!is_array($this->links)) {
$this->links = array();
}
$this->links = array_add($this->links, $name, $link);
}
示例12: destroy
/**
* 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();
}
示例13: __construct
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');
}
示例14: toArray
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()];
}
示例15: boot
/**
* 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);
});
}