Answers for "laravel print array in associative array"

PHP
1

Create and Print Array in Laravel

In App -> project.php modal file


    // NOTE: service #1 : General Translation
    public static function translationTypes()
    {
        return collect([
          [
            'id' => '1',
            'en_title' => 'Medical',
          ],
          [
            'id' => '2',
            'en_title' => 'General',
          ],
          [
            'id' => '3',
            'en_title' => 'Commercial',
          ],
          [
            'id' => '4',
            'en_title' => 'Literary',
          ],
        ]);
    }


In Controller

            $translationTypes = Project::translationTypes();

In View 

                @foreach($translationTypes as $translationType)
                <option value="{{$translationType['id']}}">{{ $translationType['en_title'] }}</option>
                @endforeach
Posted by: Guest on September-18-2021

Code answers related to "laravel print array in associative array"

Browse Popular Code Answers by Language