Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id | name |
- id | typesoin_id | animal_id | datedusoin
- public function soinsvetos() {
- return $this->hasMany(Soinsveto::class, 'animal_id');
- }
- public function animal()
- {
- return $this->belongsTo(Animal::class, 'animal_id')->withTrashed();
- }
- public function compose(View $view)
- {
- foreach (AppAnimal::get()
- ->all() as $animal) {
- $soins = AppSoinsveto::with('typesoin')
- ->where('animal_id', $animal->id)
- ->where(function ($q) { /// 1 = primovaccin et 2 = vaccins annuels
- $q->where('typesoin_id', '=', '2')
- ->orWhere('typesoin_id', '=', '1');
- })
- ->orderBy('datedusoin', 'desc')
- ->get()
- ->first();
- if ($soins) {
- if ($soins->typesoin_id == '1' && $soins->datedusoin < Carbon::now()->subMonths(1)) {
- $crudFieldValue = Carbon::parse($soins->getOriginal('datedusoin'))->addyear(1)->toDateString();
- }
- if ($soins->typesoin_id == '2' && $soins->datedusoin < Carbon::now()->subYears(1)) {
- $crudFieldValue = Carbon::parse($soins->getOriginal('datedusoin'))->addyear(1)->toDateString();
- }
- }
- $notif[] = [
- 'title' => $soins->typesoin->nomsoin,
- 'start' => $crudFieldValue,
- 'nomanimal' => $animal->nom,
- ];
- }
- $view->with('notif', $notif);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement