public function createRootPeople($data)
    {
        $people = new People;
        $people->name = $data['name'];
        $people->surname = $data['surname'];
        $people->age = $data['age'];
        $people->gender = $data['gender'];
        $people->spouse = empty($data['spouse']) ? null : $data['spouse'];

        $root = People::create($people->attributesToArray());
        $root->makeRoot()->save();
    }
 /**
  * Get statistic data.
  *
  * @return Response
  */
 public function monthStatistic($month, $year, Request $request)
 {
     $statistics = new \stdClass();
     $StatisticEndDate = Carbon::create($year, $month, 1, 0, 0, 0)->addMonth(1);
     $StatisticStartDate = Carbon::create($year, $month, 1, 0, 0, 0);
     $statistics->companies = [Companies::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), Companies::whereNull("Deleted")->get()->count()];
     $statistics->products = [Products::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), Products::whereNull("Deleted")->get()->count()];
     $statistics->news = [News::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), News::whereNull("Deleted")->get()->count()];
     $statistics->people = [People::whereNull("Deleted")->where("Date_Created", "<", $StatisticEndDate)->where("Date_Created", ">", $StatisticStartDate)->get()->count(), People::whereNull("Deleted")->get()->count()];
     return json_encode($statistics);
 }
Exemple #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = People::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'dept_id' => $this->dept_id, 'job_id' => $this->job_id, 'edu_lvl_id' => $this->edu_lvl_id, 'edu_spec_id' => $this->edu_spec_id, 'listener_id' => $this->listener_id]);
     $query->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'patronymic', $this->patronymic])->andFilterWhere(['like', 'login', $this->login])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'sot', $this->sot])->andFilterWhere(['like', 'published', $this->published])->andFilterWhere(['like', 'postaddress', $this->postaddress])->andFilterWhere(['like', 'cellphone', $this->cellphone])->andFilterWhere(['like', 'homephone', $this->homephone]);
     return $dataProvider;
 }
Exemple #4
0
 public function Tags($categories = "All")
 {
     $tags = [];
     if ($categories == NewsCategories::All || $categories == NewsCategories::Comany) {
         foreach ($this->company()->get() as $item) {
             $tags[] = (object) ["target" => $this->target[0], "id" => $item->id_Company, "description" => $item->Company_Full_Name];
         }
     }
     if ($categories == NewsCategories::All || $categories == NewsCategories::Products) {
         foreach ($this->product()->get() as $item) {
             $tags[] = (object) ["target" => $this->target[3], "id" => $item->id_Product, "description" => $item->Product_Title];
         }
     }
     if ($categories == NewsCategories::All || $categories == NewsCategories::People) {
         foreach ($this->employee()->get() as $item) {
             $people = People::where("id_People", "=", $item->id_People)->first();
             $tags[] = (object) ["target" => $this->target[1], "id" => $item->id_People, "description" => $people->First_Name];
         }
     }
     return $tags;
 }
Exemple #5
0
 /**
  * Finds the People model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return People the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = People::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function getTagsList($category)
 {
     switch ($category) {
         case 'Companies':
             return Companies::whereNull("Deleted")->orderBy('Company_Full_Name', 'asc')->get(['id_Company as id', 'Company_Full_Name as description'])->toJson();
         case 'People':
             return People::whereNull("Deleted")->orderBy('First_Name', 'asc')->get(['id_People as id', 'First_Name as description'])->toJson();
         case 'Vertical':
             return Vertical::all(['id_Vertical as id', 'Main_Description as description'])->toJson();
         case 'Products':
             return Products::whereNull("Deleted")->orderBy('Product_Title', 'asc')->get(['id_Product as id', 'Product_Title as description'])->toArray();
         case 'Events':
             return Event::all(['id_Event as id', 'Event_Title as description'])->toJson();
     }
 }
 public function convertScript()
 {
     $data = 'data';
     Excel::load('/storage/app/Medium1.xlsx', function ($reader) use($data) {
         $existsData = [];
         $reader->each(function ($sheet) use($existsData) {
             $company = $sheet->getTitle();
             $companyModel = Companies::where("Company_Full_Name", "like", "%{$company}%")->first();
             $rowData = $sheet->toArray();
             foreach ($rowData as $row) {
                 if (isset($row) && count($row)) {
                     $name = isset($row['name']) ? trim($row['name']) : "";
                     if (!strlen($name) && in_array(strtolower($name), $existsData)) {
                         continue;
                     }
                     $title = isset($row['title']) ? trim($row['title']) : "";
                     $description = isset($row['description']) ? trim($row['description']) : "";
                     //                        $employeeType = EmployeeType::all(["Type_Name"])->toArray();
                     //
                     //                        $present = [];
                     //                        foreach ($employeeType as $aType) {
                     //                            if (!in_array($aType["Type_Name"], $present)) $present[] = strtolower($aType["Type_Name"]);
                     //                        }
                     ////                        echo "<pre>";
                     ////                        print_r($present);
                     ////                        echo "</pre>";
                     //                        $Employee_types = [];
                     //
                     //                        $ptitle = explode(",", $title);
                     //
                     //                        foreach ($ptitle as $part) {
                     //                            $title_part = trim(strtolower($part));
                     //                            if (strlen($title_part) == 0) {
                     //                                continue;
                     //                            }
                     //                            $created = false;
                     //                            foreach ($present as $item) {
                     //                                $sameLatters = similar_text(strtolower($item), $title_part, $per);
                     //                                if ($per < 80 && !in_array($title_part, $present)) {
                     //                                    $created = true;
                     //                                    $present[] = $title_part;
                     //                                    $Employee_types[] = EmployeeType::create(["Type_Name" => ucwords($title_part)]);
                     //                                }
                     //                            }
                     //                            if (!$created) {
                     //                                $Employee_types[] = EmployeeType::where("Type_Name", 'like', "%" . ucwords($title_part) . "%")->get()->first();
                     //                            }
                     //
                     //                        }
                     //
                     $flname = explode(" ", $name);
                     $peopleFields = [];
                     $addressFields = [];
                     $employeeFields = [];
                     $peopleFields['First_Name'] = is_array($flname) && isset($flname[0]) && strlen($flname[0]) ? $flname[0] : "";
                     $peopleFields['Surname'] = is_array($flname) && isset($flname[1]) && strlen($flname[1]) ? $flname[1] : "";
                     if (count($flname) == 3 && $description != "") {
                         $peopleModel = People::where("Career_Description", "like", "%{$description}%")->get();
                         if ($peopleModel->count()) {
                             foreach ($peopleModel as $pModel) {
                                 $peopleFields['Surname'] = is_array($flname) && isset($flname[2]) && strlen($flname[2]) ? $flname[2] : "";
                                 $peopleFields['Middle_Name'] = is_array($flname) && isset($flname[1]) && strlen($flname[1]) ? $flname[1] : "";
                                 echo $peopleFields['First_Name'] . " : " . $peopleFields['Middle_Name'] . " : " . $peopleFields['Surname'];
                                 $pModel->fill($peopleFields)->save();
                             }
                         }
                     }
                     //
                     //                        if ($peopleFields['First_Name'] && $peopleFields['First_Name'] || ($peopleFields['First_Name'])) {
                     //                            $addressModel = Addresses::create($addressFields);
                     //                            $peopleFields['Career_Description'] = $description;
                     //                            $peopleFields['Date_Created'] = Carbon::now();
                     //                            $peopleFields['AddressId'] = $addressModel->AddressId;
                     //                            $peopleModel = People::create($peopleFields);
                     //                            if ($companyModel) {
                     //                                $peopleModel->careerHistory()->save(new \App\Models\CareerHistory([
                     //                                    "Position_Name" => $title, "Company_Name" => $companyModel->Company_Full_Name,
                     //                                    "Current_Position_Status" => 1
                     //                                ]));
                     //                            }
                     //                            $employeeModel = $peopleModel->employee()->create($employeeFields);
                     //                            foreach ($Employee_types as $EmployeeType) {
                     //                                $employeeModel->employeeType()->save($EmployeeType);
                     //                            }
                     //
                     //                        }
                     //                        $existsData[] = strtolower($name);
                 }
                 //
                 //
                 //                     Loop through all rows
                 //                $sheet->each(function($row) {
                 //                    echo $row;
                 //                });
             }
         });
     });
 }
 private function processDelete()
 {
     $ids = $this->getRandomsNumbers(50, 50000, 1);
     $queryesExecution = array();
     $peoples = array();
     foreach ($ids as $id) {
         Debug::timer();
         // SELECT + DELETE DATA
         $people = Models\People::find($id);
         $peoples[] = $people;
         $people->delete();
         $queryesExecution[] = number_format(Debug::timer() * 1000, 2);
     }
     return array($queryesExecution, $peoples);
 }
 public function circle($id)
 {
     $circle = Circle::find($id);
     $temp = 0;
     foreach ($circle->enrollments as $enrollment) {
         if ($enrollment->people_id == Auth::user()->id) {
             $temp = 1;
             break;
         }
     }
     if ($temp == 0) {
         return 'You are not enrolled to this course!';
     }
     $circleList = Circle::all();
     $people = People::find(Auth::user()->id);
     return view('Pages.circlepage', compact('circle', 'circleList', 'people'));
 }