コード例 #1
0
 $person = ['name' => ['first' => 'Jill', 'last' => 'Schmoe']];
 echo 'name.first is ' . array_get($person, 'name.first') . "\n";
 $messageBag->add('notice', 'Array dot notation displayed.');
 echo '<hr>';
 // Collection
 $people = new Collection(['Declan', 'Abner', 'Mitzi']);
 $people->each(function ($person) {
     echo "Collection person: {$person}\n";
 });
 $messageBag->add('notice', 'Collection displayed.');
 echo '<hr>';
 // More at http://daylerees.com/codebright/eloquent-collections
 // Fluent
 $personRecord = array('first_name' => 'Mohammad', 'last_name' => 'Gufran');
 $record = new Fluent($personRecord);
 $record->address('hometown, street, house');
 echo $record->first_name . "\n";
 echo $record->address . "\n";
 $messageBag->add('notice', 'Fluent displayed.');
 echo '<hr>';
 // Pluralizer
 $item = 'goose';
 echo "One {$item}, two " . Pluralizer::plural($item) . "\n";
 $item = 'moose';
 echo "One {$item}, two " . Pluralizer::plural($item) . "\n";
 echo '<hr>';
 // Str
 if (Str::contains('This is my fourteenth visit', 'first')) {
     echo 'Howdy!';
 } else {
     echo 'Nice to see you again.';