Skip to main content

Posts

Showing posts with the label collection methods laravel

Mostly use of collection methods in laravel

Example code here. <? php namespace App \ Http \ Controllers ; use Illuminate \ Http \ Request ; use Illuminate \ Support \ Str ; class CollectionController extends Controller {     const PROJECT_TYPES = [         'action' ,         'base resource' ,         'A W S' ,         'lara beans'     ];     const MOVIES_TYPES = [         [ 'id' => 1 , 'name' => 'action' ],         [ 'id' => 2 , 'name' => 'base resource' ],         [ 'id' => 3 , 'name' => 'A W S' ],         [ 'id' => 4 , 'name' => 'lara beans' ]     ];     function mapWithSlugs () {         dump ( 'Convert name of arrays into slug using Slug function and iterate array with map function' );         $slugs = [];         foreac...

Collection methods examples in laravel

 Collection Method use to modfy the data or get data in our required format <?php namespace App\Http\Controllers ; use Illuminate\Http\ Request ; use Illuminate\Support\ Str ; class CollectionController extends Controller {     const PROJECT_TYPES = [         'action' ,         'base resource' ,         'A W S' ,         'lara beans'     ];     const MOVIES_TYPES = [         [ 'id' => 1 , 'name' => 'action' ],         [ 'id' => 2 , 'name' => 'base resource' ],         [ 'id' => 3 , 'name' => 'A W S' ],         [ 'id' => 4 , 'name' => 'lara beans' ]     ];     function mapWithSlugs () {         dump ( 'Convert name of arrays into slug using Slug function and iterate array with map function' );        ...