Laravel Helpers
Component ID
2280995
Component name
Laravel Helpers
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Downloads
1492
Component created
Component changed
Component body
Description
--------------------------
Bring Laravel helpers function to Drupal. This module has many useful function for developer when working with Array and String. More detail about helpers read here: http://laravel.com/docs/helpers
Supported Helpers:
- Arrays
- Strings
- Miscellaneous
Example
--------------------------
<?php
// Get field value with array_get
$node = node_load(1);
$body = array_get($node->body, "und.0.safe_value");
$node->field_tags['und'][0]['tid'] = 3;
$node->field_tags['und'][1]['tid'] = 10;
$node->field_tags['und'][2]['tid'] = 1;
// Get tid value with array_fetch
$tid_arr = array_fetch($node->field_tags['und'], 'tid');
/* return array
Array
(
[0] => 3
[1] => 10
[2] => 1
)
*/
// Get image uri from image field.
$image_arr = array_fetch($node->field_image['und'], 'uri');
/* return array
Array
(
[0] => public://field/image/imagea.jpg
[1] => public://field/image/imageb.jpg
[2] => public://field/image/imagec.jpg
)
*/
?>
