app/Http/Controllers/admin/CollectController.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(Request $request)
    {
        if($request ->ajax()){
            $gcid = $request->input('gcid','');
            $goods = Goods::where('gcid',$gcid)->get();
            echo  json_encode($goods);
            return;
        }
        $users = Users::all();
        $data = Collect::all();
        return view('admin.collect.create',['title'=>'添加收藏','users'=>$users,'$data'=>$data,'cates'=>self::getcates()]);
    }
public function create ( Request $ request ) { if ( $ request -> ajax ( ) ) { $ gcid = $ request -> input ( 'gcid' , '' ) ; $ goods = Goods :: where ( 'gcid' , $ gcid ) -> get ( ) ; echo json_encode ( $ goods ) ; return ; } $ users = Users :: all ( ) ; $ data = Collect :: all ( ) ; return view ( 'admin.collect.create' , [ 'title' => '添加收藏','users' = >$users ,' $ data' = >$data, 'c a tes' = >self:: ge tcat es ()]); }
Show the form for creating a new resource.
Show the form for creating a new resource .
//判断是否是ajax发送过来的请求 // dump($gcid);