本文整理汇总了PHP中array_collapse函数的典型用法代码示例。如果您正苦于以下问题:PHP array_collapse函数的具体用法?PHP array_collapse怎么用?PHP array_collapse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_collapse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: all_tags_from_xml
/**
* @function all_tags_from_xml()
* returns an asociative array containing all selected tag-names as keys
* and all tag content as the values.
*
* @param $xml (object): The an XML object containing the relevant children
* obtained from the XML. Could be obtained by XML->children('oml', true)
* or something similar, to get all childeren in the OML namespace.
* @param $configuration (2d string array): an array configuring which fields to be
* included in the return value. $configuration can contain 4 sub arrays, 'array',
* 'csv', 'plain' and 'string'. Putting a field in one of these sub arrays, deter-
* mines
* @param $return_array (string array): The base array to add tags to. Usually, when
* some fields are already set, these can be joined with the fields to
* be set within this function.
*
* @return (MULTIPLE VALUES array): asociative array containing all selected tag-names
* as keys and all tag content as the values.
*/
function all_tags_from_xml($xml, $configuration = array(), $return_array = array())
{
$csv_tags = array();
$include = array_collapse($configuration);
foreach ($xml as $key => $value) {
if (in_array($key, $include)) {
if (array_key_exists('array', $configuration) && in_array($key, $configuration['array'])) {
// returned in plain array
if (!array_key_exists($key, $return_array)) {
$return_array[$key] = array();
}
$return_array[$key][] = $value;
} elseif (array_key_exists('csv', $configuration) && in_array($key, $configuration['csv'])) {
// returned in CSV format
if (!array_key_exists($key, $csv_tags)) {
$csv_tags[$key] = array();
}
$csv_tags[$key][] = trim($value);
} elseif (array_key_exists('plain', $configuration) && in_array($key, $configuration['plain'])) {
// returned plain (xml object)
$return_array[$key] = $value;
} elseif (array_key_exists('string', $configuration) && in_array($key, $configuration['string'])) {
// returned as string
$return_array[$key] = trim($value);
} else {
// an illegal or undefined category
}
}
}
foreach ($csv_tags as $key => $value) {
$return_array[$key] = putcsv($value);
}
return $return_array;
}
示例3: aliasFacades
public function aliasFacades()
{
$facades = [];
foreach ($this->phpna->getServices() as $package) {
if (key_exists('facades', $package) && is_array($package['facades'])) {
$facades = array_collapse([$facades, $package['facades']]);
}
}
foreach ($facades as $facade) {
$loader = AliasLoader::getInstance();
foreach ($facades as $name => $serve) {
$loader->alias($name, $serve);
}
}
}
示例4: sliceData
private function sliceData($sezione, $prodotti_raw, $pagine_repo, $listini_repo)
{
$listini = $listini_repo->getAllFront();
$contenuti = $pagine_repo->getContentForPage($sezione);
$prodotti = [];
foreach ($prodotti_raw as $prodotto) {
$prodotti[strtoupper($prodotto['nome'])][] = $prodotto;
}
$categorie = collect(array_pluck(array_collapse($prodotti), 'categoria_terapeutica'))->unique();
$principi_validi = array_pluck(collect(array_pluck(array_collapse($prodotti), 'principio_attivo'))->unique(), 'slug');
$principi = collect(array_sort(array_pluck(array_collapse($prodotti), 'principio_attivo'), function ($value) {
return $value['nome'];
}))->unique();
return array($prodotti, $categorie, $principi, $principi_validi, $contenuti, $listini);
}
示例5: getQuemSomos2
public function getQuemSomos2()
{
$gp = DB::table('members')->where('diretoria', 'gp')->where('cargo', 'diretor')->get();
$ge = DB::table('members')->where('diretoria', 'ge')->where('cargo', 'diretor')->get();
$proj = DB::table('members')->where('diretoria', 'proj')->where('cargo', 'diretor')->get();
$jufin = DB::table('members')->where('diretoria', 'jufin')->where('cargo', 'diretor')->get();
$pres = DB::table('members')->where('diretoria', 'pres')->where('cargo', 'diretor')->get();
$mkt = DB::table('members')->where('diretoria', 'mkt')->where('cargo', 'diretor')->get();
$conselho = DB::table('members')->where('cargo', 'conselheiro')->get();
$gp = array_collapse([$gp, DB::table('members')->where('diretoria', 'gp')->where('cargo', 'assessor')->get()]);
$ge = array_collapse([$ge, DB::table('members')->where('diretoria', 'ge')->where('cargo', 'assessor')->get()]);
$proj = array_collapse([$proj, DB::table('members')->where('diretoria', 'proj')->where('cargo', 'assessor')->get()]);
$jufin = array_collapse([$jufin, DB::table('members')->where('diretoria', 'jufin')->where('cargo', 'assessor')->get()]);
$mkt = array_collapse([$mkt, DB::table('members')->where('diretoria', 'mkt')->where('cargo', 'assessor')->get()]);
return view('quem2')->with(['gp' => $gp, 'ge' => $ge, 'proj' => $proj, 'jufin' => $jufin, 'pres' => $pres, 'mkt' => $mkt, 'conselho' => $conselho]);
}
示例6: reportePedidos
public function reportePedidos($codigos)
{
$value = explode(",", $codigos);
$codigoNegocio = (int) $value[0];
$codigoLocal = (int) $value[1];
$negocio = \DB::table('negocio')->select('negocio.razonsocial', 'negocio.ruc', 'negocio.telefono', 'negocio.correo', 'logonegocio.nombre')->where('negocio.codigo', $codigoNegocio)->join('logonegocio', 'logonegocio.codigonegocio', '=', 'negocio.codigo')->first();
$raw = \DB::raw("CONCAT(persona.nombres, ' ', persona.apellidopaterno,' ', persona.apellidomaterno) as cliente");
$raw2 = \DB::raw("(select SUM(DOP.total) from detalleordenpedido as DOP where DOP.codigoordenpedido= ordenpedido.codigo ) as total");
$PedidosCP = \DB::table('ordenpedido')->select('ordenpedido.codigo', 'ordenpedido.via', 'ordenpedido.estado', 'ordenpedido.numero', 'ordenpedido.fechaemision', $raw, $raw2)->distinct()->where('detalleordenpedido.codigonegocio', $codigoNegocio)->where('detalleordenpedido.codigolocal', $codigoLocal)->where('ordenpedido.estado', 'R')->join('detalleordenpedido', 'detalleordenpedido.codigoordenpedido', '=', 'ordenpedido.codigo')->join('persona', 'persona.codigo', '=', 'ordenpedido.codigoclientepersona')->get();
$PedidosCE = \DB::table('ordenpedido')->select('ordenpedido.codigo', 'ordenpedido.via', 'ordenpedido.estado', 'ordenpedido.numero', 'ordenpedido.fechaemision', 'clienteempresa.razonsocial as cliente', $raw2)->distinct()->where('detalleordenpedido.codigonegocio', $codigoNegocio)->where('detalleordenpedido.codigolocal', $codigoLocal)->where('ordenpedido.estado', 'R')->join('detalleordenpedido', 'detalleordenpedido.codigoordenpedido', '=', 'ordenpedido.codigo')->join('clienteempresa', 'clienteempresa.codigo', '=', 'ordenpedido.codigoclienteempresa')->get();
$Pedidos = array_collapse([$PedidosCE, $PedidosCP]);
$pdf = new reportePedidos();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 10);
$pdf->cabecera($negocio);
$pdf->BasicTable($Pedidos);
$pdf->Output('reportePedidos', 'F');
exit;
}
示例7: processScreenResults
public function processScreenResults($screen_response)
{
//dd(json_decode($screen_response));
$screen_response = json_decode($screen_response);
$screen_symbols = array();
foreach ($screen_response as $page) {
$page_symbols = $page->pageFunctionResult;
array_push($screen_symbols, $page_symbols);
}
$screen_symbols = collect(array_collapse($screen_symbols));
$screen_instances = $screen_symbols->map(function ($screen_symbol) {
$instance = new Instance();
$symbol = new Symbol();
//Transform to an instance
$symbol = $symbol->firstOrCreate(['symbol' => $screen_symbol->symbol]);
$instance->source_type = 'screener';
$instance->source_name = $screen_symbol->source_name;
//Save new instances
$symbol->instances()->save($instance);
return $instance;
});
return $screen_instances;
}
示例8: UpdateAction
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function UpdateAction(ProductEditFormRequest $request, $id)
{
if ($request->get('pcategories')) {
if ($request->get('category')) {
$p = [$request->get('pcategories'), $request->get('category')];
$value = array_collapse($p);
$product = products::find($id);
if ($product) {
$product->name = $request->get('name');
$product->is_active = $request->get('is_active');
$product->description = $request->get('description');
$product->price = $request->get('price');
$product->starting_pound = $request->get('starting_pound');
$product->ending_pound = $request->get('ending_pound');
$product->save();
$product->category()->sync($value);
return redirect()->route('cake/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_SUCCESS', ['message' => 'The product table item updated']));
}
return redirect()->route('cake/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_ALERT', ['message' => 'The product could not updated']));
}
return redirect()->route('cake/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_ALERT', ['message' => 'The product could not updated']));
}
return redirect()->route('cake/list')->with('message', Lang::get('response.CUSTOM_MESSAGE_ALERT', ['message' => 'The product could not updated']));
}
示例9: update
public function update(array $reps)
{
$divisions = [];
foreach ($reps as $rep) {
if (!empty($rep->division) && !in_array($rep->division, $divisions)) {
array_push($divisions, $rep->division);
}
}
$requests = array_map(function ($d) {
return GoogleAPI::division($d);
}, $divisions);
$results = Promise\unwrap($requests);
return array_collapse(array_map(function ($result) {
return $result->reps;
}, $results));
}
示例10: __construct
public function __construct()
{
$this->defaults = ['title' => 'Home', 'title-spacer' => ' – ', 'title-description' => 'Laravel Blue', 'keywords' => array_collapse([['home'], ['laravel', 'blue', 'cms', 'meestorhok']]), 'description' => 'This amazing site was created by Laravel Blue!', 'images' => [], 'twitter' => '@BlueCMS', 'copyright' => '© 2016 Laravel Blue', 'robots' => 'index,follow', 'colors' => ['safari_pinned' => '#151e4f', 'ms_tile' => '#ffffff', 'theme' => '#151e4f']];
}
示例11: array
</div>
<div class="form-group">
{!! Form::label( @trans('auth.email') ) !!}
{!! Form::text('email', null, ['class' => 'form-control']) !!}
</div>
<!-- select -->
<div class="form-group">
{!! Form::label( @trans('prado.role') ) !!}
<?php
$lista = array();
foreach ($roles as $role) {
$lista[] = array($role->name => $role->name);
}
$lista = array_collapse($lista);
?>
@if ($user->exists)
<?php
//trae el primer registro desde roles
$user_roles = $user->roles()->first();
$name = $user_roles['name'];
?>
{!! Form::select('role', $lista, $name, ['class' => 'form-control']) !!}
@else
{!! Form::select('role', $lista, null, ['class' => 'form-control']) !!}
@endif
</div>
<div class="form-group">
示例12: update
public function update(Request $request, PhotoChild $photoChild)
{
$photoChild->update($request->except('file', 'tag_kg', 'tag_ru', 'q'));
$tag_kg_string = $request->input('tag_kg');
$tags = explode("; ", $tag_kg_string);
$tag_ru_string = $request->input('tag_ru');
$tags2 = explode("; ", $tag_ru_string);
if (!empty($tags)) {
foreach ($tags as $key => $name) {
if (!is_numeric($name) && !empty($name)) {
$tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
$tag->name = $name;
$tag->save();
$tags[$key] = $tag->id();
}
}
// $post->tags()->sync($tags);
}
// end if
if (!empty($tags2)) {
foreach ($tags2 as $key => $name) {
if (!is_numeric($name) && !empty($name)) {
$tag = \Model\Tag\Tag::firstOrNew(['name' => $name]);
$tag->name = $name;
$tag->save();
$tags2[$key] = $tag->id();
}
}
// $post->tags()->sync($tags2);
}
// end if
$tagsCommon = array_collapse([$tags, $tags2]);
$photoChild->tags()->sync($tagsCommon);
if ($request->hasFile('file')) {
$file = $request->file('file');
$time = time();
$dir = 'froala/uploads';
$name = $photoChild->id() . $time . '.' . $file->getClientOriginalExtension();
$storage = \Storage::disk('public');
$storage->makeDirectory($dir);
Image::make($_FILES['file']['tmp_name'])->heighten(600)->save($dir . '/' . $name);
$photoChild->file = $dir . '/' . $name;
$photoChild->save();
}
return redirect()->route('admin.photoChild.show', $photoChild);
}
示例13: scopeUnrated
public function scopeUnrated($query, $course_id = null)
{
$course = Course::findBySlugOrId($course_id);
$tasks = $course->tasks();
$tasksIds = $tasks->get(['id'])->toArray(['id']);
$articlesTaskIds = array_flatten(Article::whereIn('task_id', array_flatten($tasksIds))->get(['id'])->toArray());
$articlesWithoutAnyRating = Article::whereNotExists(function ($query) {
$query->select(DB::raw(1))->from('ratings')->whereRaw('articles.id = ratings.article_id');
})->whereIn('articles.id', $articlesTaskIds)->get(['articles.id'])->toArray();
$articlesWithSomeRating = Article::whereExists(function ($query) {
$query->select(DB::raw(1))->from('ratings')->whereRaw('articles.id = ratings.article_id')->where('ratings.text', '=', '');
})->whereIn('articles.id', $articlesTaskIds)->get(['articles.id'])->toArray();
$articles = array_collapse([array_flatten($articlesWithoutAnyRating), array_flatten($articlesWithSomeRating)]);
return $query->whereIn('id', $articles);
}
示例14: lista
public function lista(Request $request)
{
$raw = \DB::raw("CONCAT(persona.nombres, ' ', persona.apellidopaterno,' ', persona.apellidomaterno) as cliente");
$listaV = \DB::table('documentoventa')->select('documentoventa.codigo', 'documentoventa.via', 'detalleordenpedido.codigoordenpedido', $raw, 'documentoventa.totalventa', 'documentoventa.estado', 'documentoventa.numero', 'documentoventa.fechaemision')->distinct()->where('detalleordenpedido.codigonegocio', $request->codigoNegocio)->where('detalleordenpedido.codigolocal', $request->codigoLocal)->join('detalleordenpedido', 'detalleordenpedido.codigoordenpedido', '=', 'documentoventa.codigoordenpedido')->join('persona', 'persona.codigo', '=', 'documentoventa.codigoclientepersona')->join('pago', 'pago.codigodocumentoventa', '=', 'documentoventa.codigo')->get();
$listaV2 = \DB::table('documentoventa')->select('documentoventa.codigo', 'documentoventa.via', 'detalleordenpedido.codigoordenpedido', 'clienteempresa.razonsocial as cliente', 'documentoventa.totalventa', 'documentoventa.estado', 'documentoventa.numero', 'documentoventa.fechaemision')->distinct()->where('detalleordenpedido.codigonegocio', $request->codigoNegocio)->where('detalleordenpedido.codigolocal', $request->codigoLocal)->join('detalleordenpedido', 'detalleordenpedido.codigoordenpedido', '=', 'documentoventa.codigoordenpedido')->join('clienteempresa', 'clienteempresa.codigo', '=', 'documentoventa.codigoclienteempresa')->join('pago', 'pago.codigodocumentoventa', '=', 'documentoventa.codigo')->get();
$Ventas = array_collapse([$listaV, $listaV2]);
return response()->json(['msg' => "Success", 'listaVentas' => $Ventas], 200);
}
示例15: ReporterAdd
public function ReporterAdd(Request $request)
{
$lc = app()->getlocale();
$backgroundMain = \Model\Background\ModelName::where('published', '=', true)->first();
$reporter = \Model\PeopleReporter\ModelName::create($request->except('images', 'video', 'q'));
$images = $request->file('images');
$rules = array('image' => 'image');
$result = array();
if ($request->hasFile('images')) {
foreach ($images as $key => $image) {
$target = array('image' => $image);
$validator = Validator::make($target, $rules);
if ($validator->fails()) {
return redirect()->route('front.reporter');
} else {
$storage = \Storage::disk('public');
$destinationPath = 'froala/uploads';
$storage->makeDirectory($destinationPath);
$filename = time() . $key . '.' . $image->getClientOriginalExtension();
Image::make($_FILES['images']['tmp_name'][$key])->heighten(600)->save($destinationPath . '/' . $filename);
$files_array = array();
$files_array = array_collapse([$files_array, ['id' => $key + 1, 'name' => $filename]]);
$result = array_add($result, $key, $files_array);
$jsonresult = json_encode($result);
$reporter->thumbnail = $jsonresult;
$reporter->save();
}
}
}
$video = $request->file('video');
$video_rules = array('video' => 'mimes:mimes:m4v,avi,flv,mp4,mov,3gp | max:51200');
if ($request->hasFile('video')) {
$targetVideo = array('video' => $video);
$validator = Validator::make($targetVideo, $video_rules);
if ($validator->fails()) {
return redirect()->route('front.reporter');
} else {
$storage = \Storage::disk('public');
$destinationPath = 'froala/videos';
$storage->makeDirectory($destinationPath);
$filename = time() . '.' . $video->getClientOriginalExtension();
$video->move($destinationPath, $filename);
$reporter->video = $filename;
$reporter->save();
}
}
return redirect()->route('front.reporter');
}