Esempio n. 1
0
 public function AllCommentForProviderForDataTable($pr_provider_id)
 {
     try {
         $data = PrComments::join('pr_providers as p', 'pr_comments.pr_provider_id', '=', 'p.id')->join('users as u', 'pr_comments.user_id', '=', 'u.id')->select('pr_comments.*', DB::raw('CONCAT("' . asset('') . '", u.picture) AS picture_user'), DB::raw('CONCAT("' . asset('') . '", pr_comments.picture) AS picture_comment'), 'u.name', 'u.lastname', DB::raw("(if(pr_comments.flagactive='1','Activo',(if(pr_comments.flagactive='0','Inactivo','-')))) as flagactive"), DB::raw("(if(pr_comments.flagactive='1','lock',(if(pr_comments.flagactive='0','unlock','-')))) as estado"))->where('p.id', '=', $pr_provider_id)->where('u.flagactive', '=', User::STATE_USER_ACTIVE)->orderBy('pr_comments.datecreate', 'desc');
         return $data;
     } catch (Exception $exc) {
         echo $exc->getTraceAsString();
         exit;
     }
 }
Esempio n. 2
0
 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', '!=', PrProviders::Type_Inactivo)->orderBy('pr_providers.lastupdate', 'desc')->first();
     $data = $dataProviders == null ? [] : $dataProviders->toArray();
     if ($data != []) {
         $data['comments'] = PrComments::join('users as u ', 'u.id', '=', 'pr_comments.user_id')->select('pr_comments.*', DB::raw('CONCAT("' . asset('') . '", pr_comments.picture) AS picture_comment'), DB::raw('CONCAT("' . asset('') . '", u.picture) AS picture_user'), DB::raw('CONCAT(u.name, " ", u.lastname) AS name_user'))->where('pr_comments.pr_provider_id', '=', $idProvider)->orderBy('pr_comments.datecreate', 'desc')->get()->toArray();
         $value = $data['name_type'] == PrProviders::Type_Premium ? 'get' : 'first';
         $dataPictureProvider = PrPictures::wherePrProviderId($idProvider)->select('flagactive', 'datecreate', DB::raw('CONCAT("' . asset('') . '", url) AS picture'))->{$value}();
         $data['picture_provider'] = $dataPictureProvider == null ? [] : $dataPictureProvider->toArray();
     }
     return $data;
 }