Exemplo n.º 1
0
 /**
  * Update the specified Prospects in storage.
  * @param  int              $id
  * @param UpdateProspectsRequest $request
  * @return Response
  */
 public function update($id, UpdateProspectsRequest $request)
 {
     $prospects = $this->prospectsRepository->find($id);
     if (empty($prospects)) {
         Flash::error('Prospects not found');
         return redirect(route('prospects.index'));
     }
     $prospects = $this->prospectsRepository->updateRich($request->all(), $id);
     $prospect = \App\Prospect::find($id);
     $foto = $prospect->foto;
     $fotoNovo = $request->foto;
     if ($fotoNovo) {
         if ($foto) {
             if (\File::exists(base_path() . '/public/images/' . $foto)) {
                 \File::Delete(base_path() . '/public/images/' . $foto);
             }
         }
         $extfoto = pathinfo(Input::file('foto')->getClientOriginalName());
         $nomefoto = ProspectsController::getRandomHex(24) . '.' . trim(strtolower($extfoto['extension']));
         Image::make(Input::file('foto'))->save(base_path() . '/public/images/prospect' . $id . '-' . $nomefoto);
         $prospect->foto = 'prospect' . $id . '-' . $nomefoto;
     }
     $prospect->save();
     Flash::success('Prospects updated successfully.');
     $prospect->interests()->detach();
     $interests = $request->input('interests');
     if (isset($interests)) {
         foreach ($interests as $interest) {
             $prospect->interests()->attach($interest);
         }
     }
     return redirect(route('prospects.index'));
 }
Exemplo n.º 2
0
 /**
  * Return general figures about the prospects.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function figures()
 {
     $prospects = Prospect::all()->count();
     $contacts = Prospect::contacted()->get()->count();
     return response()->json(compact('prospects', 'contacts'));
 }
Exemplo n.º 3
0
 public function showUserBasedList()
 {
     $sales_sum = Prospect::where('status_closed', '1')->sum('sale_amount');
     $sales_quantity = Prospect::where('status_closed', '1')->sum('sale_quantity');
     $closed_count = Prospect::where('status_closed', '1')->count();
     $not_interested_count = Prospect::where('status_not_interested', '1')->count();
     $distinct_users = Prospect::select(array(DB::raw('DISTINCT `users`.`name`'), 'users.id'))->leftJoin('users', function ($join) {
         $join->on('users.id', '=', 'prospects.user_id');
     })->get();
     $prospects = array();
     foreach ($distinct_users as $distinct_user) {
         $prospects[$distinct_user->id] = Prospect::where('user_id', $distinct_user->id)->orderBy('due_contact_date', 'asc')->get();
         $prospects[$distinct_user->id] = $prospects[$distinct_user->id]->reverse();
     }
     return view('user_prospects')->with('distinct_users', $distinct_users)->with('prospects', $prospects)->with('sales_sum', $sales_sum)->with('sales_quantity', $sales_quantity)->with('not_interested_count', $not_interested_count)->with('closed_count', $closed_count);
 }