Example #1
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         $players = DB::connection('game')->table('player_characters')->get();
         foreach ($players as $player) {
             if (!Player::where('id', $player->id)->exists()) {
                 $player_info = ['id' => $player->id, 'name' => $player->given_name, 'level' => $player->level, 'class' => 0, 'gold' => $player->gold, 'family_name' => $player->family_id ? DB::connection('game')->table('family')->where('id', $player->family_id)->first()->name : '-'];
                 Player::create($player_info);
             }
         }
     })->everyTenMinutes();
     $schedule->call(function () {
         $families = DB::connection('game')->table('family')->get();
         foreach ($families as $family) {
             if (!Family::where('id', $family->id)->exists()) {
                 $gold = 0;
                 foreach (DB::connection('game')->table('player_characters')->where('family_id', $family->id)->get() as $player) {
                     $gold += $player->gold;
                 }
                 $family_info = ['id' => $family->id, 'name' => $family->name, 'level' => $family->lv, 'gold' => $gold, 'members' => DB::connection('game')->table('player_characters')->where('family_id', $family->id)->count(), 'leader' => DB::connection('game')->table('player_characters')->where('id', $family->leader_id)->first()->given_name];
                 Family::create($family_info);
             }
         }
     })->everyTenMinutes();
 }
Example #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $users = User::where('type', 'ecole')->get();
     foreach ($users as $user) {
         $sc = SchoolYear::where('user_id', $user->id)->where('current', 1)->first();
         if ($sc) {
             if ($sc->type == 'Semis' && $sc->endch2 < Carbon::now()->toDateString() || $sc->type == 'Trim' && $sc->endch3 < Carbon::now()->toDateString()) {
                 foreach ($user->families as $famille) {
                     $f = Family::where('email_responsable', $famille->email_responsable)->where('school_year_id', $sc->id)->first();
                     if ($f) {
                         $f->email_responsable = $sc->ann_scol . $f->email_responsable;
                         $f->cin = $sc->cin . $f->cin;
                         $f->save();
                         $fu = User::where('type', 'famille')->where('email', substr($f->email_responsable, 9))->first();
                         if ($fu) {
                             $fu->email = $sc->ann_scol . $fu->email;
                             $fu->save();
                         }
                     }
                 }
                 $sc->current = 0;
                 $sc->save();
                 $ynow = Carbon::now()->year;
                 $ynext = Carbon::now()->year + 1;
                 $yes = SchoolYear::where('user_id', $user->id)->where('ann_scol', $ynow . '-' . $ynext)->first();
                 if ($yes) {
                     $yes->current = 1;
                     $yes->save();
                 }
             }
         }
     }
 }
 public function show(Person $person)
 {
     $logged_in_user = \Auth::user();
     $id = $person->id;
     $solo_images = Image::where('subject', $id)->orderBy('year', 'asc')->get();
     $featured_image = Image::where('subject', $id)->orderBy('year', 'asc')->Where('featured', 1)->get();
     $made_family = PeopleController::get_made_family($person);
     $notes = PeopleController::get_notes_about_person($person);
     $origin_family = Family::where('id', $person->family_of_origin)->first();
     return view('person.show', compact('person', 'solo_images', 'made_family', 'featured_image', 'origin_family', 'notes', 'logged_in_user'));
 }
 function get_by_specy()
 {
     $aFamilies = Family::where('species_id', Input::get('specy_id'))->get();
     /*$sHtml = '<option value="" disabled selected>Choose your Character</option>';
             foreach($aFamilies as $aFamily){
     
             }*/
     echo json_encode($aFamilies);
     //echo (Family::all()->where('species_id', Input::get('specy_id')));
     exit;
 }
Example #5
0
 public function checktoreturn(Request $request)
 {
     /* "email_resp" => "*****@*****.**"
        "fix" => "0537451258"
        "portable" => "0663083611"
        "nom_pere" => "Hamid bouslami"
        "nom_mere" => "Samar fati"*/
     if (\Request::ajax()) {
         $count = 0;
         $fix = Family::where('numero_fixe', $request->fix)->where('user_id', \Auth::user()->id)->first();
         if ($fix) {
             $count++;
         }
         $portable = Family::where('numero_portable', $request->portable)->where('user_id', \Auth::user()->id)->first();
         if ($portable) {
             $count++;
         }
         $email = Family::where('email_responsable', $request->email_resp)->where('user_id', \Auth::user()->id)->first();
         if ($email) {
             $count++;
         }
         $pere = Family::where('nom_pere', $request->nom_pere)->where('user_id', \Auth::user()->id)->first();
         if ($pere) {
             $count++;
         }
         $mere = Family::where('nom_mere', $request->nom_mere)->where('user_id', \Auth::user()->id)->first();
         if ($mere) {
             $count++;
         }
         $cin = Family::where('cin', 'LIKE', $request->cin . '%')->where('user_id', \Auth::user()->id)->first();
         if ($cin) {
             $count++;
         }
         if ($count >= 3) {
             echo 'here';
         }
     }
 }
 public function forgetpass()
 {
     if (\Request::ajax()) {
         $cin = \Input::get('cin');
         if (isset($cin) && !empty($cin)) {
             $lacarte = Family::where('cin', $cin)->first();
             if ($lacarte) {
                 $pass_without = str_random(6);
                 $user = User::where('email', $lacarte->email_responsable)->first();
                 $user->password = \Hash::make($pass_without);
                 $user->save();
                 $info = ['email' => $user->email, 'new_password' => $pass_without, 'name' => $user->nom_responsable, 'ecole' => $user->name, 'sexe' => $user->sexe, 'responsable' => $lacarte->responsable, 'date' => Carbon::now()->toDateString()];
                 Mail::queue('emails.forgetpass', $info, function ($message) use($info) {
                     $message->to($info['email'], 'ok')->from('*****@*****.**')->subject('Bienvenue  !');
                 });
                 echo 'Votre Nouveau mot de pass a bien été envoyé à votre email';
             } else {
                 echo 'Le Numéro de Cin fourni est Incorrect';
             }
         } else {
             $email = \Input::get('email');
             $email = User::where('email', $email)->whereIn('type', ['famille', 'ecole'])->first();
             if ($email) {
                 if ($email->type == 'famille') {
                     echo 'famille';
                 } elseif ($email->type == 'ecole') {
                     $utilisateur = User::where('email', $email->email)->where('type', 'ecole')->first();
                     $pass_without = str_random(6);
                     $utilisateur->password = \Hash::make($pass_without);
                     $utilisateur->save();
                     $infor = ['email' => $utilisateur->email, 'new_password' => $pass_without, 'name' => $utilisateur->nom_responsable, 'ecole' => $utilisateur->name, 'sexe' => $utilisateur->sexe, 'date' => Carbon::now()->toDateString()];
                     Mail::queue('emails.forgetpass', $infor, function ($message) use($infor) {
                         $message->to($infor['email'], 'ok')->from('*****@*****.**')->subject('Bienvenue  !');
                     });
                     echo 'Votre Nouveau mot de pass a bien été envoyé à votre email';
                 }
                 /*  Mail::send('emails.school',$info,function($message){
                 
                                     $message->to($this->email,'ok')->from('*****@*****.**')->subject('Bienvenue  !');
                 
                                 });*/
             } else {
                 echo 'cet Email est incorrect';
             }
         }
     }
 }
Example #7
0
 public function search()
 {
     $child = Child::where('nom_enfant', 'LIKE', '%' . \Input::get('terms') . '%')->where('user_id', \Auth::user()->id)->get();
     $family = Family::where('nom_pere', 'LIKE', '%' . \Input::get('terms') . '%')->where('user_id', \Auth::user()->id)->orWhere('nom_mere', 'LIKE', '%' . \Input::get('terms') . '%')->get();
     return view('families.search')->with(['child' => $child, 'family' => $family]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(FormValidationChildFamilyRequest $request)
 {
     $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $request->classe)->first();
     if ($cr->children()->where('school_year_id', $request->id_ann_scol)->count() > $cr->capacite_classe) {
         return redirect()->back()->withErrors("la classe est saturée");
     }
     // promotion Exceptional check
     if (PromotionExceptional::checkExceptionalPromotion()) {
         if (PromotionExceptional::checkExcTimeOfPromotionIfExpired()) {
             if (PromotionExceptional::checkExcPriceandReturnIt() == 'no') {
                 return redirect()->back()->withErrors("la promotion Exceptionnelle est active mais aucun prix n'est défini")->withInput();
             } else {
                 $prix_exc = PromotionExceptional::checkExcPriceandReturnIt();
             }
         } else {
             return redirect()->back()->withErrors("la promotion Exceptionnelle est active mais la durée est expirée");
         }
     }
     // promotion advanced check
     $prix_advance = '';
     if (PromotionAdvance::checkAdvancePromotion()) {
         if ($request->nbr_month > 1) {
             if (PromotionAdvance::checkAdvIfPriceIsSet($request->nbr_month) !== false) {
                 $prix_advance = PromotionAdvance::checkAdvIfPriceIsSet($request->nbr_month);
             } else {
                 return redirect()->back()->withErrors("Aucun prix n'est\n                    défini pour cette Promotion de " . $request->nbr_month . ' Mois');
             }
         }
     }
     $niveau_global = \Auth::user()->grades()->where('id', $request->grade)->first()->name;
     // famille for family profile
     $famille = Family::where('user_id', \Auth::user()->id)->where('email_responsable', $request->email_responsable)->first();
     if (!$famille) {
         $family = new Family();
         $family->nom_pere = ucfirst($request->nom_pere);
         $family->nom_mere = ucfirst($request->nom_mere);
         $family->email_responsable = $request->email_responsable;
         $family->adresse = $request->adresse;
         $family->numero_fixe = $request->numero_fixe;
         $family->numero_portable = $request->numero_portable;
         $family->cin = strtoupper($request->cin);
         $family->responsable = $request->responsable;
         $family->user_id = \Auth::user()->id;
         $family->school_year_id = $request->id_ann_scol;
         $family->save();
         if ($family->id) {
             $father = Family::findOrFail($family->id);
             $child = new Child();
             $child->date_naissance = Carbon::parse($request->date_naissance);
             $child->transport = $request->transport;
             $child->sexe = $request->sexe;
             $child->nom_enfant = ucfirst($request->nom_enfant);
             $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now());
             $child->nationalite = \DB::table('countries')->where('id', $request->nationalite)->first()->nom_fr_fr;
             $child->user_id = \Auth::user()->id;
             $child->school_year_id = $request->id_ann_scol;
             $image = \Input::file('photo');
             if (!$image && empty($image)) {
                 $filename = '';
             } else {
                 $filename = $image->getClientOriginalName();
                 $path = public_path('uploads/' . $filename);
                 Image::make($image->getRealPath())->resize(313, 300)->save($path);
             }
             $child->photo = $filename;
             $child->family_id = $family->id;
             $child->save();
             if ($child->id) {
                 $ch = Child::find($child->id);
                 if ($niveau_global == 'Lycée') {
                     $ch->branches()->attach([$request->branche]);
                 }
                 if ($niveau_global == 'Maternelle' || $niveau_global == 'Primaire' || $niveau_global == 'Collège' || $niveau_global == 'Lycée' || $niveau_global == 'Crèche') {
                     $ch->levels()->attach([$request->niveau]);
                 }
                 /*if($niveau_global == 'Crèche')
                   {
                       $ch->classrooms()->attach([$request->classe]);
                   }*/
                 //classe
                 $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $request->classe)->first();
                 $cr->children()->attach([$child->id]);
                 $bill = new Bill();
                 $bill->status = 0;
                 // if no promotion is active
                 if (!PromotionAdvance::checkAdvancePromotion() && !PromotionExceptional::checkExceptionalPromotion()) {
                     if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                         $bill->reductionPrix = $request->reduction;
                         $bill->reduction = 1;
                         $bill->school_year_id = SchoolYear::getSchoolYearId();
                         $bill->nbrMois = $request->nbr_month;
                     } else {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                         $bill->reduction = 0;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                 }
                 if (PromotionAdvance::checkAdvancePromotion()) {
                     if ($request->nbr_month >= 3) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PromotionAdvance::countAccordingTo($prix_advance, PriceBill::assignPrice($request->niveau, $request->transport), $request->nbr_month);
                         $bill->reduction = 1;
                         $bill->reductionPrix = $prix_advance;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                     if ($request->nbr_month == 1) {
                         if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                             $bill->reductionPrix = $request->reduction;
                             $bill->reduction = 1;
                             $bill->school_year_id = SchoolYear::getSchoolYearId();
                             $bill->nbrMois = $request->nbr_month;
                         } else {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                             $bill->reduction = 0;
                             $bill->school_year_id = $request->id_ann_scol;
                             $bill->nbrMois = $request->nbr_month;
                         }
                     }
                 }
                 if (PromotionExceptional::checkExceptionalPromotion()) {
                     $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                     $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                     $bill->somme = PromotionExceptional::countAccordingTo($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $prix_exc);
                     $bill->reductionPrix = $prix_exc;
                     $bill->reduction = 1;
                     $bill->school_year_id = $request->id_ann_scol;
                     $bill->nbrMois = $request->nbr_month;
                 }
                 $bill->child_id = $child->id;
                 $bill->user_id = \Auth::user()->id;
                 $bill->save();
                 $enfant = Child::findOrFail($child->id);
                 if ($father->responsable == 0) {
                     $resp = $father->nom_mere;
                 } else {
                     $resp = $father->nom_pere;
                 }
                 event(new SendEmailToRespAfterRegistrationEvent($child->id, $resp, $enfant->nom_enfant, $enfant->created_at->toDateString(), $enfant->created_at->addMonth()->toDateString(), $father->email_responsable, $father->responsable, str_random(6)));
             }
         }
         return redirect()->back()->with('success', "l'élève et les parents ont bien été ajoutés! ");
     } else {
         // if the parent already in the database
         $child = new Child();
         $child->date_naissance = Carbon::parse($request->date_naissance);
         $child->nom_enfant = $request->nom_enfant;
         $child->sexe = $request->sexe;
         $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now());
         $child->nationalite = \DB::table('countries')->where('id', $request->nationalite)->first()->nom_fr_fr;
         $child->school_year_id = $request->id_ann_scol;
         $child->transport = $request->transport;
         $child->user_id = \Auth::user()->id;
         $image = \Input::file('photo');
         if (!$image && empty($image)) {
             $filename = '';
         } else {
             $filename = $image->getClientOriginalName();
             $path = public_path('uploads/' . $filename);
             Image::make($image->getRealPath())->resize(313, 300)->save($path);
         }
         $child->photo = $filename;
         $child->family_id = $famille->id;
         $resp = Family::findOrFail($famille->id);
         $user = User::where('email', $resp->email_responsable)->first();
         if ($user) {
             $child->f_id = $user->id;
             $child->save();
             if ($child->id) {
                 $ch = Child::find($child->id);
                 if ($niveau_global == 'Lycée') {
                     $ch->branches()->attach([$request->branche]);
                 }
                 if ($niveau_global == 'Maternelle' || $niveau_global == 'Primaire' || $niveau_global == 'Collège' || $niveau_global == 'Lycée' || $niveau_global == 'Crèche') {
                     $ch->levels()->attach([$request->niveau]);
                 }
                 if ($niveau_global == 'Crèche') {
                     $ch->classrooms()->attach([$request->classe]);
                 }
                 $cr = Classroom::where('user_id', \Auth::user()->id)->where('id', $request->classe)->first();
                 $cr->children()->attach([$child->id]);
                 $bill = new Bill();
                 $bill->status = 0;
                 if (!PromotionAdvance::checkAdvancePromotion() && !PromotionExceptional::checkExceptionalPromotion()) {
                     if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                         $bill->reductionPrix = $request->reduction;
                         $bill->reduction = 1;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     } else {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                         $bill->reduction = 0;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                 }
                 if (PromotionAdvance::checkAdvancePromotion()) {
                     if ($request->nbr_month >= 3) {
                         $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                         $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                         $bill->somme = PromotionAdvance::countAccordingTo($prix_advance, PriceBill::assignPrice($request->niveau, $request->transport), $request->nbr_month);
                         $bill->reduction = 1;
                         $bill->reductionPrix = $prix_advance;
                         $bill->school_year_id = $request->id_ann_scol;
                         $bill->nbrMois = $request->nbr_month;
                     }
                     if ($request->nbr_month == 1) {
                         if (isset($request->reduction) && !empty($request->reduction) && !is_null($request->reduction)) {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotionButReduction($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $request->reduction);
                             $bill->reductionPrix = $request->reduction;
                             $bill->reduction = 1;
                             $bill->school_year_id = $request->id_ann_scol;
                             $bill->nbrMois = $request->nbr_month;
                         } else {
                             $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                             $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                             $bill->somme = PriceBill::countWhenNoPromotion($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport));
                             $bill->reduction = 0;
                             $bill->school_year_id = $request->id_ann_scol;
                             $bill->nbrMois = $request->nbr_month;
                         }
                     }
                 }
                 if (PromotionExceptional::checkExceptionalPromotion()) {
                     $bill->start = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->toDateString();
                     $bill->end = SchoolYear::find($request->id_ann_scol)->startch1->firstOfMonth()->addMonths($request->nbr_month)->toDateString();
                     $bill->somme = PromotionExceptional::countAccordingTo($request->nbr_month, PriceBill::assignPrice($request->niveau, $request->transport), $prix_exc);
                     $bill->reductionPrix = $prix_exc;
                     $bill->reduction = 1;
                     $bill->school_year_id = $request->id_ann_scol;
                     $bill->nbrMois = $request->nbr_month;
                 }
                 $bill->child_id = $child->id;
                 $bill->f_id = $user->id;
                 $bill->user_id = \Auth::user()->id;
                 $bill->save();
             }
         }
         return redirect()->back()->with('success', "l'élève a bien été ajouté! ");
     }
 }
 public function control($sUserName)
 {
     switch ($sUserName) {
         case 'logout':
             return redirect('user/logout');
         case 'characters':
             return redirect('character/index');
         case 'users':
             return redirect('user/index');
         default:
             $oUser = User::where('user_name', $sUserName)->first();
             if ($oUser == null) {
                 dd("ALALALHJ!");
             } else {
                 $aLoggedInUser = null;
                 $bOwner = false;
                 $oMate = null;
                 $bLoggedInUser = Session::has('user');
                 if ($bLoggedInUser) {
                     if ($oUser->toArray()['id'] == Session::get('user')['id']) {
                         $bOwner = true;
                     }
                     $aLoggedInUser['user'] = User::where('id', Session::get('user')['id'])->first()->toArray();
                     $aLoggedInUser['current_character'] = Character::where('id', $aLoggedInUser['user']['current_character_id'])->first()->toArray();
                 }
                 $aUser['user'] = $oUser->toArray();
                 $aUser['current_character'] = Character::where('id', $aUser['user']['current_character_id'])->first()->toArray();
                 $aUser['active_characters'] = Character::where('user_id', $aUser['user']['id'])->where('status', Character::CHARACTER_STATUS_DEFAULT)->orWhere('status', Character::CHARACTER_STATUS_ENABLED_BY_USER)->orWhere('status', Character::CHARACTER_STATUS_ENABLED_BY_ADMIN)->get()->toArray();
                 $aUser['inactive_characters'] = Character::where('user_id', $aUser['user']['id'])->where('status', Character::CHARACTER_STATUS_DISABLED_BY_USER)->orWhere('status', Character::CHARACTER_STATUS_INACTIVE)->get()->toArray();
                 $aUser['user_settings'] = UserSetting::where('user_id', $oUser->toArray()['id'])->first()->toArray();
                 $aUser['current_photo'] = Photo::where('id', $aUser['user']['photo_id'])->first()->toArray();
                 //Mates
                 $bRequestedFromLoggedInUser = false;
                 if ($bLoggedInUser) {
                     $sSql = 'SELECT * from mates where ((from_user_id = ' . $aUser['user']['id'] . ' AND to_user_id = ' . Session::get('user')['id'] . ') OR (from_user_id = ' . Session::get('user')['id'] . ' AND to_user_id = ' . $aUser['user']['id'] . ')) AND (status = ' . Mate::MATE_STATUS_ADDED_BY_USER . ' OR status <> ' . Mate::MATE_STATUS_ADDED_BY_ADMIN . ')';
                     $oMate = DB::select($sSql);
                     $oMate = Mate::where('from_user_id', $aUser['user']['id'])->orWhere('to_user_id', Session::get('user')['id'])->orWhere(function ($query) {
                         $query->where('status', Mate::MATE_STATUS_ADDED_BY_ADMIN)->where('status', Mate::MATE_STATUS_ADDED_BY_ADMIN);
                     })->orderBy('id', 'desc')->first();
                 }
                 $aUser['mate'] = is_null($oMate) || empty($oMate) ? NULL : $oMate->toArray();
                 if ($aUser['mate']['from_user_id'] == Session::get('user')['id']) {
                     $bRequestedFromLoggedInUser = true;
                 }
                 //End of mate
                 //Likes
                 $oUserUserLikers = Like::where('to_user_id', $aUser['user']['id'])->where('like_type', Like::LIKE_TYPE_USER)->where('user_id', $aUser['user']['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
                 $aUser['user']['likers'] = $oUserUserLikers ? $oUserUserLikers->toArray() : [];
                 $aUser['user']['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aUser['user']['likers'], $aLoggedInUser['user']['id']);
                 $oCurrentCharacterLikers = Like::where('to_user_id', $aUser['user']['id'])->where('like_type', Like::LIKE_TYPE_CHARACTER)->where('character_id', $aUser['user']['current_character_id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
                 $aUser['current_character']['likers'] = $oCurrentCharacterLikers ? $oCurrentCharacterLikers->toArray() : [];
                 $aUser['current_character']['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aUser['current_character']['likers'], $aLoggedInUser['user']['id']);
                 for ($i = 0; $i < count($aUser['active_characters']); $i++) {
                     $aActiveCharacterLikers = Like::where('to_user_id', $aUser['user']['id'])->where('like_type', Like::LIKE_TYPE_CHARACTER)->where('character_id', $aUser['active_characters'][$i]['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
                     $aUser['active_characters'][$i]['likers'] = $aActiveCharacterLikers ? $aActiveCharacterLikers->toArray() : [];
                     $aUser['active_characters'][$i]['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aUser['active_characters'][$i]['likers'], $aLoggedInUser['user']['id']);
                 }
                 for ($i = 0; $i < count($aUser['inactive_characters']); $i++) {
                     $aInActiveCharacterLikers = Like::where('to_user_id', $aUser['user']['id'])->where('like_type', Like::LIKE_TYPE_CHARACTER)->where('character_id', $aUser['inactive_characters'][$i]['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
                     $aUser['inactive_characters'][$i]['likers'] = $aInActiveCharacterLikers ? $aInActiveCharacterLikers->toArray() : [];
                     $aUser['inactive_characters'][$i]['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aUser['inactive_characters'][$i]['likers'], $aLoggedInUser['user']['id']);
                 }
                 $oCurrentPhotoLikers = Like::where('to_user_id', $aUser['user']['id'])->where('like_type', Like::LIKE_TYPE_PHOTO)->where('photo_id', $aUser['current_photo']['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
                 $aUser['current_photo']['likers'] = $oCurrentPhotoLikers ? $oCurrentPhotoLikers->toArray() : [];
                 $aUser['current_photo']['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aUser['current_photo']['likers'], $aLoggedInUser['user']['id']);
                 //dd($aUser);
                 $aFamilies = Family::where('status', Family::FAMILY_STATUS_DEFAULT)->get()->toArray();
                 $aSpecies = Specy::where('status', Specy::SPECY_STATUS_DEFAULT)->get()->toArray();
                 return view('users.users.profile')->with('aLoggedInUser', is_array($aLoggedInUser) ? $aLoggedInUser : null)->with('aUser', $aUser)->with('bOwner', $bOwner)->with('bRequestedFromLoggedInUser', $bRequestedFromLoggedInUser)->with('bLoggedInUser', $bLoggedInUser)->with('aSpecies', $aSpecies)->with('aFamilies', $aFamilies);
             }
     }
 }
 function get_comments_by_photo_id()
 {
     $iFromType = Input::get('from_type');
     $iFromID = Input::get('from_id');
     $aLoggedInUser = User::where('id', Session::get('user')['id'])->first()->toArray();
     switch ($iFromType) {
         case Comment::COMMENT_FROM_TYPE_USER:
             $aFromItem = User::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_USER)->where('user_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('user_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
         case Comment::COMMENT_FROM_TYPE_CHARACTER:
             $aFromItem = Character::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_CHARACTER)->where('character_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('character_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
         case Comment::COMMENT_FROM_TYPE_FAMILY:
             $aFromItem = Family::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_FAMILY)->where('family_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('family_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
         case Comment::COMMENT_FROM_TYPE_SPECY:
             $aFromItem = Specy::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_SPECY)->where('specy_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('specy_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
         case Comment::COMMENT_FROM_TYPE_PHOTO:
             $aFromItem = Photo::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_PHOTO)->where('photo_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('photo_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
         case Comment::COMMENT_FROM_TYPE_POST:
             $aFromItem = Post::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_POST)->where('post_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('post_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
         case Comment::COMMENT_FROM_TYPE_MATE:
             $aFromItem = Mate::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_MATE)->where('mate_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('mate_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
         default:
             $aFromItem = User::where('id', $iFromID)->first()->toArray();
             $oItemLikers = Like::where('like_type', Like::LIKE_TYPE_USER)->where('user_id', $aFromItem['id'])->where('status', Like::LIKE_STATUS_ACTIVE)->get();
             $aFromItem['likers'] = is_array($oItemLikers->toArray()) && count($oItemLikers->toArray()) ? $oItemLikers->toArray() : [];
             $aFromItem['logged_in_user']['has_liked'] = LikesController::checkHasLikedInArray($aFromItem['likers'], $aLoggedInUser['id']);
             $oComments = Comment::where('user_id', $iFromID)->where('status', Comment::COMMENT_STATUS_DEFAULT)->get();
             break;
     }
     $oComments = is_array($oComments->toArray()) && count($oComments->toArray() > 0) ? $oComments->toArray() : [];
     $aComments = null;
     $iFromWhereID = null;
     for ($i = 0; $i < count($oComments); $i++) {
         $aComments[$i] = $oComments[$i];
         $aComments[$i]['from_user'] = User::where('id', $oComments[$i]['from_user_id'])->first()->toArray();
         if ($oComments[$i]['comment_photo_id'] > 0) {
             $aComments[$i]['photo_comment'] = Photo::where('id', $oComments[$i]['comment_photo_id'])->first()->toArray();
         }
         $iFromType = $oComments[$i]['comment_from_type'];
         switch ($iFromType) {
             case Comment::COMMENT_FROM_TYPE_USER:
                 $iFromWhereID = "user_id";
                 $aComments[$i]['from'] = User::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
             case Comment::COMMENT_FROM_TYPE_CHARACTER:
                 $iFromWhereID = "character_id";
                 $aComments[$i]['from'] = Character::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
             case Comment::COMMENT_FROM_TYPE_FAMILY:
                 $iFromWhereID = "family_id";
                 $aComments[$i]['from'] = Family::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
             case Comment::COMMENT_FROM_TYPE_SPECY:
                 $iFromWhereID = "specy_id";
                 $aComments[$i]['from'] = Specy::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
             case Comment::COMMENT_FROM_TYPE_PHOTO:
                 $iFromWhereID = "photo_id";
                 $aComments[$i]['from'] = Photo::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
             case Comment::COMMENT_FROM_TYPE_POST:
                 $iFromWhereID = "post_id";
                 $aComments[$i]['from'] = Post::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
             case Comment::COMMENT_FROM_TYPE_MATE:
                 $iFromWhereID = "mate_id";
                 $aComments[$i]['from'] = Mate::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
             default:
                 $iFromWhereID = "user_id";
                 $aComments[$i]['from'] = User::where('id', $oComments[$i][$iFromWhereID])->first()->toArray();
                 break;
         }
     }
     $view = view('users.comments.show')->with('aComments', $aComments);
     $htmlFromWhatView = view('users.comments.partials.partial-comment-from-what-display')->with('aFromItem', $aFromItem)->with('iFromType', $iFromType);
     if ($oComments) {
         return response()->json(['view' => (string) $view, 'status' => true, 'message' => "Successfully archived character", 'what_to_display' => (string) $htmlFromWhatView]);
     } else {
         $htmlFromWhatView = view('users.comments.partials.partial-comment-from-what-display')->with('aFromItem', $aFromItem)->with('iFromType', $iFromType);
         $view = view('users.comments.show')->with('aComments', []);
         if ($htmlFromWhatView != "") {
             return response()->json(['view' => (string) $view, 'status' => true, 'message' => "Successfully archived character", 'what_to_display' => (string) $htmlFromWhatView]);
         } else {
             echo json_encode(array('status' => false, 'message' => "Something went wrong. Please try again later"));
         }
     }
     die;
 }
Example #11
0
        <li class="menu_li">
            <img src="{{ asset('images/tableau_de_bord.png')  }}" alt="">
            <a href="{{ url('index') }}">
                Tableau de bord</a>
        </li>
        <li class="menu_li"> <img src="{{ asset('images/qui_sommes_nous.png')  }}" alt="" id="qui_sommes_nous"><a href="">Qui sommes nous ?</a></li>
        <li class="menu_li"> <img src="{{ asset('images/contactez_nous.png')  }}" alt="" id="contactez_nous"><a href="" >Contactez-nous</a></li>
        <li class="menu_li"> <img src="{{ asset('images/comment_ca_marche.png')  }}" alt="" id="comment_ca_marche"><a href="" >Comment Ca marche</a></li>
    </ul>
    <div class="account" id="account">


        <a href="{{ \Auth::user()->isAdmin() ? action('SchoolsController@edit',[\Auth::user()->id]): '' }}">
         @if(Auth::user() && Auth::user()->isFamily())
                <?php 
$resp = \App\Family::where('email_responsable', Auth::user()->email)->first();
if ($resp->responsable == 0) {
    echo 'Bienvenue ' . $resp->nom_mere;
} else {
    echo 'Bienvenue ' . $resp->nom_pere;
}
?>
             @else

             {{ 'Bienvenue '. \Auth::user()->name  }}


            @endif
        </a>
       <img src="{{  asset('images/user.png') }}" alt="user">
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $file = fopen("/home/daniel/Downloads/new_file.csv", "r");
     while (!feof($file)) {
         print_r(fgetcsv($file));
         $row = fgetcsv($file);
         $family_name = $row[1];
         $user_name = $row[2];
         $church_id = 1;
         $church = Church::find($church_id);
         // $zone_hash = {};
         // $zone_hash["0"] = $church->zones()->where("name","=","Zone 0")->first()->id;
         // $zone_hash["1"] = $church->zones()->where("name","=","Zone 1")->first()->id;
         // $zone_hash["2"] = $church->zones()->where("name","=","Zone 2")->first()->id;
         // $zone_hash["3"] = $church->zones()->where("name","=","Zone 3")->first()->id;
         // $zone_hash["4"] = $church->zones()->where("name","=","Zone 4")->first()->id;
         // $zone_hash["5"] = $church->zones()->where("name","=","Zone 5")->first()->id;
         // $no_zone = $church->zones()->where("name","=","No Zone")->first()->id;
         $user = App\User::where("name", "=", $user_name)->where("church_id", "=", $church_id)->first();
         $family = App\Family::where("name", "=", $family_name)->first();
         if ($user) {
             if ($family) {
                 $family_id = $family->id;
                 if ($family_id == $user->family_id) {
                 } else {
                     $user->family_id = $family_id;
                     $user->save();
                 }
             } else {
                 $new_family = new Family();
                 $new_family->name = $row[1];
                 $new_family->save();
                 User::whereIn("id", $user->id)->update(["family_id" => $new_family->id]);
             }
         } else {
             $new_user = new User();
             $new_user->name = $row[2];
             $new_user->dob = $row[4];
             $new_user->weddingDate = $row[5];
             $new_user->baptism_taken = trim($row[6]) == "YES" ? true : false;
             $new_user->annointing_taken = trim($row[7]) == "YES" ? true : false;
             $new_user->phone_number = $row[8];
             $new_user->email = $row[9];
             $new_user->member_type = trim($row[10]) == "YES" ? 0 : 2;
             $new_user->address = $row[11] + $row[12] + $row[13] + $row[14];
             switch (trim($row[15])) {
                 case "0":
                     $new_user->zone_id = $church->zones()->where("name", "=", "Zone 0")->first()->id;
                     break;
                 case "1":
                     $new_user->zone_id = $church->zones()->where("name", "=", "Zone 1")->first()->id;
                     break;
                 case "2":
                     $new_user->zone_id = $church->zones()->where("name", "=", "Zone 2")->first()->id;
                     break;
                 case "3":
                     $new_user->zone_id = $church->zones()->where("name", "=", "Zone 3")->first()->id;
                     break;
                 case "4":
                     $new_user->zone_id = $church->zones()->where("name", "=", "Zone 4")->first()->id;
                     break;
                 case "5":
                     $new_user->zone_id = $church->zones()->where("name", "=", "Zone 5")->first()->id;
                     break;
                 default:
                     $new_user->zone_id = $church->zones()->where("name", "=", "No Zone")->first()->id;
             }
             $new_user->church_id = $church_id;
             if ($family) {
                 $family_id = $family->id;
                 $new_user->family_id = $family_id;
                 $new_user->save();
             } else {
                 $new_family = new Family();
                 $new_family->name = $row[1];
                 $new_family->save();
                 $new_user->family_id = $new_family->id;
                 $new_user->save();
             }
         }
     }
     fclose($file);
 }