Answers for "laravel relation return array"

PHP
0

laravel relation return array

/**
     * Show all themes from a specific language
     *
     * @param Language $language
     * @return \Illuminate\Database\Eloquent\Collection
     */
    public function show(string $abbreviation)
    {
        return Theme::whereHas('language', function ($query) use ($abbreviation) {
            $query->where('abbreviation', '=', $abbreviation);
        })->get()->map(function ($theme) {
           $theme['items'] = $theme->items()->get()->pluck('item')->all();
           return $theme;
        })->all();
    }
Posted by: Guest on October-06-2021

Code answers related to "laravel relation return array"

Browse Popular Code Answers by Language