Please can any one tell me how I can show the meta key value in view the array which im getting output is below:
[0] => Resource Object
(
[presenter:protected] => ResourcePresenter
[table:protected] => resources
[parentColumn:protected] => parent_id
[leftColumn:protected] => lft
[rightColumn:protected] => rgt
[depthColumn:protected] => depth
[guarded:protected] => Array
(
[0] => id
[1] => parent_id
[2] => lft
[3] => rgt
[4] => depth
)
[orderColumn:protected] =>
[scoped:protected] => Array
(
)
[connection:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[id] => 551
[parent_id] => 180
[lft] => 383
[rgt] => 384
[depth] => 1
[owner_id] => 41
[type] => 2
[title] => test
[act_name] => 551.jpg
[display_name] => test
[notes] =>
[size] => 3054
[is_archived] => 0
[created_by] => 41
[created_at] => 2016-07-12 07:30:54
[updated_by] => 41
[updated_at] => 2016-07-12 07:30:56
[created] => 2016-07-12 07:30:54
[updated] => 2016-07-12 07:30:54
)
[original:protected] => Array
(
[id] => 551
[parent_id] => 180
[lft] => 383
[rgt] => 384
[depth] => 1
[owner_id] => 41
[type] => 2
[title] => test
[act_name] => 551.jpg
[display_name] => test
[notes] =>
[size] => 3054
[is_archived] => 0
[created_by] => 41
[created_at] => 2016-07-12 07:30:54
[updated_by] => 41
[updated_at] => 2016-07-12 07:30:56
[created] => 2016-07-12 07:30:54
[updated] => 2016-07-12 07:30:54
)
[relations:protected] => Array
(
[resourceMeta] => Illuminate\Database\Eloquent\Collection Object
(
[items:protected] => Array
(
[0] => ResourceMeta Object
(
[table:protected] => resources_info
[timestamps] =>
[fillable:protected] => Array
(
[0] => resource_id
[1] => key
[2] => value
)
[connection:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[attributes:protected] => Array
(
[id] => 1924
[resource_id] => 551
[key] => doc_type
[value] => jpg
)
[original:protected] => Array
(
[id] => 1924
[resource_id] => 551
[key] => doc_type
[value] => jpg
)
I want to print the file_Type value of each document please help me how can I achieve it.
Basically for this First need to get the meta value in loop and then extract it for example:
<?php
foreach($folderFiles as $file)
$metaArg1=array();
foreach ($file->ResourceMeta as $key => $value) {
$metaArg1[$value->key] = $value->value;
}
}
echo $metaArg1['doc_Type'];
?>
Basically you can add a relationship on your model:
On your model:
public function TableMeta()
{
return $this->hasMany('App\Models\TableMeta');
}
Then on your controller:
$query = Model::with('TableMeta')->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.