114. //--------------------------------------------------------------------------------------------------
115. public function view()
116. {
117. $auth = md5(date('Ymd'));
118. $key = \URI::key();
119. if ($key != $auth) {
120. DB::where('int:is_active', true);
121. }
122. $id = \URI::view();
123. $company = Perpa\Company::view($id);
124.
125.
126. if (empty($company)) {
127. redirect(URL::site('page-not-found'));
128. }
129.
130. if ($company->id !== $company->parent_id) {
131. $url = str_replace('view/'.$company->id, 'view/'.$company->parent_id, URL::current() );
132. Redirect::action( $url);
133.
330. break;
331. default:
332. $color = 'bg-grey';
333. }
334.
335. return $color;
336. }
337.
338.
339. public static function view(Int $id)
340. {
341. $where = [];
342. $where[] = ['int:id', $id];
343.
344. $perpa = \Perpa\Company::viewSql();
345. DB::where($where);
346. $company = DB::get($perpa . 'AS perpa')->row();
347. #output(DB::stringQuery());
348. return $company;
349. }