コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     //listing all farmer when no search is done
     $allfarmer = User::where('user_type_id', 3)->paginate(10);
     //$allfarmer = User::where('user_type_id', 3)->get(); /previous code
     //listing Farmerpoint for dropdown
     $farmerPointList = FarmerPoint::Lists('name', 'id');
     $cropList = Crop::Lists('name', 'id');
     //recieving data from search field
     $farmer_name = $request->input('name');
     $farmer_phone = $request->input('phone');
     $farmerInPoint = $request->input('id');
     $farmerWithCrop = $request->input('crop');
     if (!empty($farmer_name)) {
         $allfarmer = User::where('user_type_id', 3)->where('name', 'LIKE', '%' . $farmer_name . '%')->paginate(10);
     }
     if (!empty($request->phone)) {
         $allfarmer = User::where('user_type_id', 3)->where('phone', 'LIKE', '%' . $farmer_phone . '%')->paginate(10);
     }
     if (!empty($farmerInPoint)) {
         if (!empty($farmerWithCrop)) {
             $allfarmer = User::whereHas('farmerCrop', function ($query) use($farmerWithCrop) {
                 $query->where('crop_id', $farmerWithCrop);
             })->where('user_type_id', 3)->where('farmer_point_id', $farmerInPoint)->paginate(10);
         } else {
             $allfarmer = User::where('user_type_id', 3)->where('farmer_point_id', $farmerInPoint)->paginate(10);
         }
     }
     if (!empty($farmerWithCrop)) {
         $allfarmer = User::whereHas('farmerCrop', function ($query) use($farmerWithCrop) {
             $query->where('crop_id', $farmerWithCrop);
         })->where('user_type_id', 3)->paginate(10);
     }
     return view('farmer.FarmerList', ['allfarmer' => $allfarmer, 'farmerPointList' => $farmerPointList, 'cropList' => $cropList]);
 }
コード例 #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $cropList = Crop::lists('name', 'id')->all();
     $upazilaList = Upazila::lists('name', 'id')->all();
     $crop = FarmerCrop::findOrFail($id);
     return view('Farmer.FarmerCropEdit', compact('crop', 'cropList', 'upazilaList'));
 }
コード例 #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->all();
     $crop = Crop::findOrFail($id);
     $crop->update($input);
     if (!empty($request->profile_picture)) {
         $image = Image::make($request->profile_picture);
         $image->resize(250, 272);
         $image->save(public_path("uploads/Crops/crop_{$id}.jpg"));
     }
     return redirect("crop/{$crop->id}");
 }