app/Http/Controllers/ArticlesController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        $categories=[];
        $categories=Category::where('category_id', '=', '0')
                            ->orderBy('name','ASC')
                            ->get()
                            ->map(function($category){
                                return ['name' => $category->name, 'categories' => $category->downcategory->pluck('name','id')->toArray()];
                            })->keyBy('name')->map(function($categories) {
                                return $categories['categories'];
                            });
        return view("admin.articles.create")
                ->with('categories',$categories);
    }
public function create ( ) { $ categories = [ ] ; $ categories = Category :: where ( 'category_id' , '=' , '0' ) -> orderBy ( 'name' , 'ASC' ) -> get ( ) -> map ( function ( $ category ) { return [ 'name' => $ category -> name , 'categories' => $ category -> downcategory -> pluck ( 'name' , 'id' ) -> toArray ( ) ] ; } ) -> keyBy ( 'name' ) -> map ( function ( $ categories ) { return $ categories [ 'categories' ] ; } ) ; return view ( " admin.articles.create " ) -> with ( 'categories' , $ categories ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .
//dd($categories);