コード例 #1
0
 public function postForm(FormProviderRequest $request)
 {
     $id = $request->input('id', NULL);
     $message = "Se ingresó correctamente el proveedor.";
     $modelProvider = new PrProviders();
     $data = $request->all();
     try {
         if (isset($id) && $id != '') {
             $provider = $modelProvider->find($id);
             $provider->fill($data);
             $provider->save();
             $message = "Se actualizó la información del proveedor de manera correcta.";
         } else {
             $modelProvider->fill($data);
             $modelProvider->save($data);
         }
     } catch (Exception $ex) {
     }
     return redirect('admpanel/provider')->with('messageSuccess', $message);
 }
コード例 #2
0
ファイル: PrProviders.php プロジェクト: josmel/buen
 public function ProviderForDataTable($condicion, $valoracion = null)
 {
     $dataProviders = PrProviders::join('pr_types', 'pr_providers.pr_type_id', '=', 'pr_types.id');
     if ($valoracion != null) {
         $dataProviders = $dataProviders->join('pr_comments as prc', 'pr_providers.id', '=', 'prc.pr_provider_id');
     } else {
         $dataProviders = $dataProviders->leftJoin('pr_comments as prc', 'pr_providers.id', '=', 'prc.pr_provider_id');
     }
     $dataProviders = $dataProviders->select('pr_types.name_type', 'pr_providers.*', DB::raw('COUNT(prc.id) as valoracion'), DB::raw('CONCAT("' . asset('') . '", picture_face) AS picture_face'), DB::raw("(if(pr_providers.flagactive='1','Activo',(if(pr_providers.flagactive='0','Inactivo','-')))) as flagactive"), DB::raw("(if(pr_providers.flagactive='1','lock',(if(pr_providers.flagactive='0','unlock','-')))) as estado"))->where('pr_types.name_type', $condicion, PrProviders::Type_Inactivo)->groupby('pr_providers.id')->orderBy('pr_providers.pr_type_id', 'desc')->orderBy('pr_providers.ranking', 'desc')->orderBy('pr_providers.lastupdate', 'desc')->groupBy('pr_providers.id');
     return $dataProviders;
 }
コード例 #3
0
ファイル: ProvidersController.php プロジェクト: josmel/buen
 /**
  *
  * @return Response
  */
 public function store(RegisterProviderRequest $request)
 {
     try {
         $dataProvider = $request->all();
         $dataProvider['user_id'] = $this->_identity->id;
         $objProvider = PrProviders::create($dataProvider);
         $this->_responseWS->setDataResponse(Response::HTTP_CREATED, ['id' => $objProvider->id], [], 'ok');
     } catch (\Exception $exc) {
         $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, array(), array(), '');
     }
     $this->_responseWS->response();
 }
コード例 #4
0
ファイル: PrPictures.php プロジェクト: josmel/buen
 public function getProvider($idProvider)
 {
     $dataProviders = PrProviders::join('pr_types', 'pr_providers.pr_type_id', '=', 'pr_types.id')->leftJoin('pr_pictures', 'pr_pictures.pr_provider_id', '=', 'pr_providers.id')->select('pr_types.name_type', 'pr_providers.*', DB::raw('CONCAT("' . asset('') . '", picture_face) AS picture_face'))->where('pr_providers.id', '=', $idProvider)->where('pr_types.name_type', '!=', 'inactivo')->orderBy('pr_providers.lastupdate', 'desc')->first();
     $data = $dataProviders == null ? [] : $dataProviders->toArray();
     return $data;
 }
コード例 #5
0
ファイル: ProviderController.php プロジェクト: josmel/buen
 public function getDelete($id)
 {
     $result = array('state' => 0, 'msg' => '');
     try {
         if (!$id) {
             throw new \Exception("Id de provider vacio");
         }
         $user = PrProviders::whereId($id)->first();
         $flagactive = $user->flagactive == 0 ? 1 : 0;
         $user->update(['id' => $id, 'flagactive' => $flagactive]);
         $result['state'] = 1;
     } catch (\Exception $e) {
         $result['msg'] = $e->getMessage();
     }
     return response()->json($result);
 }