Ibe

Ibe

Member Since 1 Year Ago

Experience Points 2,810
Experience Level 1

2,190 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 3
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

22 Feb
1 day ago

Ibe started a new conversation Js Stopt Working Because Of Vue?

Hi there, so I am having a problem with laravel vue and I don't know why it happens... Maybe someone here can help.

So basically I need to add this section to the bottom of my code to let some components work on the page. But somehow this part prevents my js file to be loaded in on the page...

@section('scripts')

  <script>
    var app = new Vue({
      el: '#app',
      data: {
      }
    });
  </script>

@endsection

This script should be loaded on the page, which it doesn't..

<script type="text/javascript" src="{{ asset('js/map.js') }}"></script>

What is happening and how can I solve this? Thanks!!

17 Feb
6 days ago

Ibe started a new conversation How Can I Join 2 Tables And Sort Them By Date

Hi there, I don't really know how I can join two tables together in Laravel... Hopefully, someone can help here. So basically I have the regulars table and the commemoratives table. I would like all the items in to show them by date. So now there are separate from each other, but how can I merge/join them together?

Controller:

  public function getCoins(){
    $regulars = Regular::all();
    $commemoratives = Commemorative::all();

    return view('pages/all-coins')->withRegulars($regulars)->withCommemoratives($commemoratives);
  }

blade:

  @foreach ($regulars as $regular)


  @endforeach


  @foreach ($commemoratives as $commemorative)


  @endforeach

Thanks!!

13 Feb
1 week ago

Ibe left a reply on How To Sort A GroupBy?

thanks!!

Ibe started a new conversation How To Sort A GroupBy?

Hi there, I am having a problem to sort a groupBy.. So this code works perfectly, but the problem is my years are displaying in a random order.. So what I would love is to see the most recent year on top and the others following. Can someone help me pls?

Controller

  public function getCommemorative(){
    $commemoratives = Commemorative::orderBy('month', 'desc')->paginate(15)->groupBy('year');

    return view('pages/commemorative')->withCommemoratives($commemoratives);
  }

Blade

@foreach ($commemoratives as $year => $commemoratives)

    <h1>{{ $year }}</h1>

    @foreach ($commemoratives->where('jointly_id', '') as $commemorative)

        <div class="">
          <img src="/images/commemorative-coins/{{$commemorative->image}}" class="" alt="">
        </div>

    @endforeach

@endforeach

Thanks!!

12 Feb
1 week ago

Ibe left a reply on How To Get The Count Of Grouped Collection?

@CRONIX - First one first like a charm, thanks!!

Ibe started a new conversation How To Get The Count Of Grouped Collection?

Hi there, I am having a problem with a specific count.. So I want to get the count of the Countries that have category set to Capital. How can I do this??

blade:

{{$countsCapitals}}

Controller:

  public function getCountry(){
    $country = Country::orderBy('name')->get();
    $countsCapitals = Country::where('category = Capital')->count();
    return view('pages/country')->withCountries($country)->with('countsCapitals', $countsCapitals);
  }

In database: http://prntscr.com/mkal26

Thanks!!

11 Feb
1 week ago

Ibe left a reply on How Do I Count Items In Show Page With Relationships

@ronb1985 then I get this error: Property [id] does not exist on this collection instance.

Ibe started a new conversation How Do I Count Items In Show Page With Relationships

Hi there, im having a problem with the counts and I really don't know how to solve it.. So I would like to count all the items (commemorative) in the 'Jointly show' page. The commemoratives belong to a jointly, they are linked by id. Does anyone know how I can solve this?

PagesController:

  public function getJointlyShow($name){
    $jointlies = Jointly::whereName($name)->first();
    $count = Commemorative::count();
  
    return view('pages/jointly-show')->withJointlies($jointlies)->with('count', $count);;
  }

jointly-show.blade.php:

    {{ $count }}

    @foreach ($jointlies->commemoratives->sortBy('country:name') as $commemoratives)

            <span>{{$commemoratives->title}}</span>

    @endforeach

Thanks!!

24 Jan
4 weeks ago

Ibe started a new conversation Ordening Foreach Code Problem

Hi there, I am having a little ordening my code.. maybe someone can help:

@foreach ($commemoratives->where('year', '2018') as $commemorative)

    <h1>2018</h1>

    <div class="">
              <img src="/images/commemorative/{{$commemorative->image}}"/>
    </div>

@endforeach

@foreach ($commemoratives->where('year', '2017')  as $commemorative)

    <h1>2017</h1>

    <div class="">
              <img src="/images/commemorative/{{$commemorative->image}}"/>
    </div>

@endforeach

@foreach ($commemoratives->where('year', '2016') as $commemorative)

    <h1>2016</h1>

    <div class="">
              <img src="/images/commemorative/{{$commemorative->image}}"/>
    </div>

@endforeach

...

So I need a way to clean this code... its getting very messy and I hope there is a way I can write it easyer... But I really don't know how..

Thanks if you can help!

22 Jan
1 month ago

Ibe left a reply on Problem With Navigating Threw Show Page

@CRONIX - Aww, im stupid, thank you very much!

Ibe started a new conversation Problem With Navigating Threw Show Page

Hi there, I am having a little problem with navigating threw my country show pages. So on the country show page I have two arrows to navigate threw my show pages. This code normally works if I pass threw the id in the controller. Now on the country page, it needs to loop threw the name of the country.

I tried to make it work so it would loop threw the name, but I didn't get it to work, maybe someone here can help me...

Route:

Route::get('country/{name}', '[email protected]');

Controller:

  public function getCountryShow($name){
    $country = Country::whereName($name)->first();
    $next = Country::where('id', '<', $country->name)->orderBy('id', 'desc')->first();
    $previous = Country::where('id', '>', $country->name)->first();
    return view('pages/country-show', ['countries' => $country])->with('next', $next)->with('previous', $previous);
  }

Blade.php

              <a href="{{$next->id}}">
                <span class="fa-icon">
                <i class="fa fa-angle-left"></i>
                </span>
                <!--<span>Previous</span>-->
              </a>

              <a href="{{$previous->id}}">
                <!--<span>Next</span>-->
                <span class="fa-icon">
                <i class="fa fa-angle-right"></i>
                </span>
              </a>

Thanks!!

20 Jan
1 month ago

Ibe left a reply on How To Make Related To Section

@VILFAGO - Awesome!! This works perfectly! Thanks you very much!!

Ibe left a reply on How To Make Related To Section

@VILFAGO - Hi there, this works fine for me, but just one small problem: So in the foreach loop it show all the similar coins, but including the coin that is already show in the 'show page'. Is there a way I can show all the similar coins, but not the one that is already shown on the page..??

I hope you understand the question... Really thanks for the help! I appriciate it very much!

Ibe started a new conversation How To Make Related To Section

Hi there, I am having a problem to show some related items on the 'show page'. So what I would love to see on the show page is a related to section that show all related coins (based on value and their country).

pagesController.php

  public function getRegularShow($id){
    $regulars = Regular::find($id);
    return view('pages/regular-show')->withRegulars($regulars);
  }

regular-show.blade.php

// this shows the coin image on the show page
<div class="com-coin-image">
              <img src="/images/regular-coins/{{$regulars->image}}" alt="Placeholder image" class="com-coin-image">
 </div>

// This has to show the other related one-cent coins with the same country
  @foreach ($regulars->where('value', 'one-cent') as $regular)

    <img src="/images/regular-coins/{{$regulars->image}}" alt="Placeholder image" class="">

  @endforeach

Database: http://prntscr.com/m9pti2

I do not get an error on this, but it also doesn't show the related coins.. Can someone help please,

Thanks!

07 Jan
1 month ago

Ibe left a reply on Showing Linked Items Problem

Worked, thanks!

Ibe started a new conversation Showing Linked Items Problem

Hi friends, I am having a little problem with linked items, anyone can help pls? So you have 'regular coins' that are linked to a country by id (country_id). I want to show a full overview in the regular.blade of the country and 'regular coins' that belong to them. Each coin also has a value (see scr shot database), so this I would also like to be sorted...

Regular coins database: http://prntscr.com/m45ivu

Controller:

  public function getRegular(){
    $regulars = regular::all();
    return view('pages/regular')->withRegulars($regulars);
  }

regular.blade.php

<!--not working-->
@foreach ($countries as $country)

  <h1>Country name</h1>

  <!--sorted per value -> one-cent, two-cent, five-cent, ten-cent,...-->
  <ul>
    <li>Image of one-cent coin here</li>
    <li>Image of two-cent coin here</li>
    <li>Image of five-cent coin here</li>
    <li>Image of ten-cent coin here</li>
    <li>Image of twenty-cent coin here</li>
    ...
  </ul>

@endforeach

So what I would like is a list of all countries, each country shows the regular coins that belong to that country. And those coins need to be sorted by value (one-cent, two-cent, five-cent, ...)

Thanks to anyone who can help!!

22 May
9 months ago

Ibe started a new conversation Password Updating Problem

Hi there, I am having a problem with my password updating... In the profile page you have a radio button to keep the password and a radio button to change the password. The change radio button pops-up the password field and so you can change your password. The problem is when I leave the password radio button on keep, it changes the password to nothing -> so the original password doesn't work and I have no access to the account anymore..

Someone know how to fix this?

profile controller:

  public function update_profile(Request $request)
    {

      $this->validate($request, [
     'name' => 'required|max:255',
     'email' => 'required|email',
     'telephone' => 'sometimes|max:15',
     'function' => 'sometimes',
     'password' => 'sometimes'
   ]);



      $admin = Auth::user();
      $admin->name = $request->name;
      $admin->email = $request->email;
      $admin->telephone = $request->telephone;

      if ($request->password_options == 'keep'){

      } elseif ($request->password_options == 'change'){
        $admin->password = Hash::make($request->password);
      }


      $admin->save();

      // Set flash data with succes message
      $request->session()->flash('update', 'Profiel succesvol ge├╝pdate!');

        return view('admin.profiles.profile', array('admin' => Auth::user()) );



    }

profile blade:

    <div class="field">

                <div class="control">

                  <div class="field">

                  <label class="radio">
                    <input type="hidden" name="password_options" value="keep" checked>
                    <b-radio v-model="password_options" native-value="keep" name="keep">Don't change password</b-radio>
                  </label>
                  </div>



                  <div class="field">
                  <label class="radio">
                    <input type="hidden" name="password_options" value="change">
                    <b-radio v-model="password_options" native-value="change" name="change">Change password</b-radio>
                    <p class="control">
                      <input type="text" class="input is-rounded fullwidth" name="password" id="password" v-if="password_options == 'change'" placeholder="New password" >
                    </p>
                  </label>
                  </div>

                </div>
        </div>

Thanks!

14 May
9 months ago

Ibe started a new conversation How To Get Todays Records

Hi there, I am trying to get the todays records of checkins and checkouts belonging to a child... but the 'whereDate' method is not working.. What am I doing wrong?

ChildController:

    public function show($id)
    {
      $child = Child::find($id);


      // Define a Closure that will apply grouping to each Collection.
      $groupingChecks = function ($check) {
          return $check->created_at->whereDate('created_at', Carbon::today())->get();
      };

      // Apply grouping on each relation
      $groupedCheckin = $child->checkin->groupBy($groupingChecks);
      $groupedCheckout = $child->checkout->groupBy($groupingChecks);

      return view('admin.children.show', compact('child', 'groupedCheckin', 'groupedCheckout'));

    }

show:

@foreach ($groupedCheckin as $date => $checkins)
  <br>
    {{ $date }}
  <br>

    @foreach($checkins as $checkin)
    <strong>Checkin:</strong>
        {{$checkin->checkin}}
    @endforeach


@endforeach


@foreach ($groupedCheckout as $date => $checkouts)
  <br>
    {{ $date }}
  <br>

    @foreach($checkouts as $checkout)
    <strong>Checkout:</strong>
        {{$checkout->checkout}}
    @endforeach


@endforeach 

Thanks

08 May
9 months ago

Ibe started a new conversation How To Get Today's Rows With Many To Many Relationship

Hi there, I am having a problem with showing the today's rows on a many to many relationship:

So I have children, checkins and checkouts (all stored separetly in the database). The checkins and checkouts belongs to children. In the index page I would like to show each child and every child has a checkin and checkout (could be more), but I would like to show only those of today.

Child model:

class Child extends Model
{

  public function checkin()
  {
    return $this->belongsToMany('App\Checkin');
  }
  public function checkout()
  {
    return $this->belongsToMany('App\Checkout');
  }

}

Checkin model:

class Checkin extends Model
{
  public function child()
  {
    return $this->belongsToMany('App\Child');
  }
}

Checkout model:

class Checkout extends Model
{
  public function child()
  {
    return $this->belongsToMany('App\Child');
  }
}

CheckController:

public function index()
    {
      $children = Child::all();
      $checkins = Checkin::whereDate('created_at', Carbon::today())->get(); 
      return view('admin.checks.index', compact('children'))->withCheckins($checkins);
    }

index:

  @foreach ($children as $child)
  <div class="field card">
      {{$child->name}}


  <h1>Checkin at:</h1>
  <?php foreach ($child->checkin as $checkin): ?>

      <h1>{{$checkin->checkin}}</h1>

  <?php endforeach; ?>


  <h1>Checkout at:</h1>
  <?php foreach ($child->checkout as $checkout): ?>

      <h1>{{$checkout->checkout}}</h1>

  <?php endforeach; ?>

  </div>

  @endforeach 

The checkin variable in the 'CheckController' works, but because I am iterating threw all the checkins of a child in my index page. It just show them all... and I just want to show the ones of today.

This shows only the checkins of today, but if I add this in the index page inside the child loop it show for each chil the same checkin, so it doesn't apply well...

      <?php foreach ($checkins as $checkin): ?>

          <h1>{{$checkin->checkin}}</h1>

      <?php endforeach; ?>

Does someone know how to do this please?

Thanks!

01 May
9 months ago

Ibe started a new conversation Showing Todays Records For Each Child

Hi there, I am having a problem showing the records today for each child.

So in the controller I am showing only the checkins and checkouts for today. This is working well because I get the right collection after: https://prnt.sc/jcghq0

But the problem is in my blade... it's iterating over all the children with all checkins and checkouts... So in my blade I just it's not showing only for today...

Does someone know how to solve this?

CheckController:

public function index()
    {
      $children = Child::all();
      $checkins = Checkin::whereDate('created_at', Carbon::today())->get();
      $checkouts = Checkout::whereDate('created_at', Carbon::today())->get();
      return view('admin.checks.index', compact('checkins', 'checkouts', 'children'));
    }

Blade:

@foreach ($children as $child)
      <figure class="image is-64x64">
        <img src="/images/children/{{$child->photo}}" class="rounded-image" alt="Placeholder image">
      </figure>
      {{$child->name}}


  <h1>Checkin at::</h1>
  {{$child->checkin->count() == 0 ? 'Not checked in!' : ''}}
  <?php foreach ($child->checkin as $checkin): ?>

      <h1>{{$checkin->checkin}}</h1>

  <?php endforeach; ?>


  <h1>Checkout at:</h1>
  {{$child->checkout->count() == 0 ? 'Not checked out!' : ''}}
  <?php foreach ($child->checkout as $checkout): ?>

      <h1>{{$checkout->checkout}}</h1>

  <?php endforeach; ?>

  @endforeach 

Thanks

Ibe left a reply on How To Get Only Records Created Today?

@Cronix yh I see the problem, but have no idea how to fix it.. Do you know how to approach this?

Ibe left a reply on How To Get Only Records Created Today?

@Cronix Sorry so this is what I have now:

CheckController:

public function index()
    {
      $children = Child::all();
      $checkins = Checkin::whereDate('created_at', Carbon::today())->get();
      $checkouts = Checkout::whereDate('created_at', Carbon::today())->get();
      return view('admin.checks.index', compact('checkins', 'checkouts', 'children'));
    }

blade:

@foreach ($children as $child)
  <div class="field card">
      <figure class="image is-64x64">
        <img src="/images/children/{{$child->photo}}" class="rounded-image" alt="Placeholder image">
      </figure>
      {{$child->name}}


  <h1>Checkin at::</h1>
  {{$child->checkin->count() == 0 ? 'Not checked in!' : ''}}
  <?php foreach ($child->checkin as $checkin): ?>

      <h1>{{$checkin->checkin}}</h1>

      <a class="button is-outlined is-rounded m-r-5" href="{{route('checkin.show', $checkin->id)}}">View</a>
      <a class="button is-light" href="{{route('checkin.edit', $checkin->id)}}">Edit</a>
  <?php endforeach; ?>


  <h1>Checkout at:</h1>
  {{$child->checkout->count() == 0 ? 'Not checked out!' : ''}}
  <?php foreach ($child->checkout as $checkout): ?>

      <h1>{{$checkout->checkout}}</h1>
      <a class="button is-outlined is-rounded m-r-5" href="{{route('checkout.show', $checkout->id)}}">View</a>
      <a class="button is-light" href="{{route('checkout.edit', $checkout->id)}}">Edit</a>
  <?php endforeach; ?>

  </div>

  @endforeach 

Ibe left a reply on How To Get Only Records Created Today?

@Cronix The collection is getting the right one --> http://prntscr.com/jcghq0 But in my blade its just show them all... do I need to change something there?

Ibe left a reply on How To Get Only Records Created Today?

@Cronix hmm didn't work either.. thanks

Ibe left a reply on How To Get Only Records Created Today?

@rin4ik Did nothing.. thanks

Ibe started a new conversation How To Get Only Records Created Today?

Hi there, I don't really know how to show the records that are only created today... Can someone help please?

So I have a list of children and each child has a checkin and checkout, what I would like is to show only the checkins and checkouts that are created today.. they both have a created_at

CheckController:

public function index()
    {
      $children = Child::all();
      $checkins = Checkin::all(); //only show for today
      $checkouts = Checkout::all(); //only show for today
      return view('admin.checks.index')->withCheckins($checkins)->withCheckouts($checkouts)->withChildren($children);
    }

Thanks!

30 Apr
9 months ago

Ibe left a reply on Grouping Multiple Tables Under Same Created_at..

Yeah correct, but does someone know how to do this? Because really im lost with this.. :(

26 Apr
9 months ago

Ibe left a reply on Grouping Multiple Tables Under Same Created_at..

@burlresearch I added your method to my code, but this bring up my collection very strange way and multiple time.. Does someone know what im doing wrong?

ChildController:

  public function show($id)
    {
      $child = Child::find($id);

      // Define a Closure that will apply grouping to each Collection.

   $allActs = $child->actone
   ->concat($child->acttwo)
   ->concat($child->actthree)
   ->groupBy(function ($activity) {
           return $activity->created_at->format('Y-m-d');
   });

      $next = Child::where('id', '<', $child->id)->orderBy('id', 'desc')->first();
      $previous = Child::where('id', '>', $child->id)->first();
      return view('admin.children.show', compact('child', 'allActs'))->with('next', $next)->with('previous', $previous);
    }

Show.blade.php:

@foreach ($allActs as $date => $activities)

  <strong>{{ $date }}</strong>

    @foreach($activities as $activity)


    <?php foreach ($child->actone as $actone): ?>
      <h1>ETEN</h1>

      <td>{{$actone->category}}</td>
      <td>{{$actone->time}}</td>
      <td>{{$actone->name}}</td>
      <td>{{$actone->rating}}</td>
      <td>{{$actone->comment}}</td>

    <?php endforeach; ?>

    <?php foreach ($child->acttwo as $acttwo): ?>
      <h1>SLAPEN</h1>

      <td>{{$acttwo->time_from}}</td>
      <td>{{$acttwo->time_to}}</td>
      <td>{{$acttwo->rating}}</td>
      <td>{{$acttwo->comment}}</td>

    <?php endforeach; ?>

    <?php foreach ($child->actthree as $actthree): ?>
      <h1>MEDICATIE</h1>

      <h1>{{$actthree->medication}}</h1>
      <h1>{{$actthree->time}}</h1>
      <h1>{{$actthree->prescription}}</h1>
      <h1>{{$actthree->comment}}</h1>

    <?php endforeach; ?>



    @endforeach

@endforeach

Ibe left a reply on Grouping Multiple Tables Under Same Created_at..

@burlresearch Thanks I will give this a shot

Ibe started a new conversation Grouping Multiple Tables Under Same Created_at..

Hi there, does anyone know how to sort data per day from multiple tables? I am still struggling with this...

So I have multiple tables (actone, acttwo, actthree,...). Each one of them contains the timestamps with the created_at. How can I group actone, acttwo, actthree,... under the same date? Can anyone help please?

How I would like my view: https://prnt.sc/j6f73w

ChildController:

public function show($id)
    {
      $child = Child::find($id);

      return view('admin.children.show')->withChild($child);
    }

Show.blade.php:

<?php foreach ($child->actone as $actone): ?>

          <td>{{$actone->category}}</td>
          <td>{{$actone->time}}</td>
          <td>{{$actone->name}}</td>
          <td>{{$actone->rating}}</td>
          <td>{{$actone->comment}}</td>
      <td>{{$actone->created_at}}</td>

        <?php endforeach; ?>


        <?php foreach ($child->acttwo as $acttwo): ?>

          <td>{{$acttwo->time_from}}</td>
          <td>{{$acttwo->time_to}}</td>
          <td>{{$acttwo->rating}}</td>
          <td>{{$acttwo->comment}}</td>
      <td>{{$acttwo->created_at}}</td>

        <?php endforeach; ?>

        <?php foreach ($child->actthree as $actthree): ?>

          <h1>{{$actthree->medication}}</h1>
          <h1>{{$actthree->time}}</h1>
          <h1>{{$actthree->prescription}}</h1>
          <h1>{{$actthree->comment}}</h1>
      <td>{{$actthree->created_at}}</td>

        <?php endforeach; ?>
    
    ...

Thanks!!

24 Apr
9 months ago

Ibe left a reply on How To Show Children Based On Gender

@cronix @devk yh it was Man with capital letters, sorry stupid of me :p But really thanks guys!!

Ibe left a reply on How To Show Children Based On Gender

@Cronix dd gets me: http://prntscr.com/j9l4jp but its not working.. I tried this:

        @php
              $males = $children->where('gender', 'man');
              @endphp

              @foreach($children as $male)

              {{ $child->name }}

              @endforeach 

But its not working either..

Ibe started a new conversation How To Show Children Based On Gender

Hi there, does anyone know how I can show only children based on their gender ('man' or 'vrouw')

I my application I made some 3 tabs: first tab shows all the children, second tab should show all the boys and the third tab should show al the girls. I am able to show all the children, but how can I 'filter' the foreach loop so it only selects the children that are boys or girls.

Everytime I add a new child you can add the gender. This passes a string value 'man' or 'vrouw' to the database.

Blade:

<b-tabs position="is-centered" class="block">
            <b-tab-item label="All"> <!--first tab-->
              @foreach ($children as $child)
              <div class="field" class="checkbox" >
                <b-checkbox name="children[]" native-value="{{$child->id}}" class="checkbox">
                  <div class="checkbox">
                    <figure class="image is-64x64">
                      <img src="/images/children/{{$child->photo}}" class="rounded-image" alt="Placeholder image">
                    </figure>
                    {{$child->name}}
                  </div>

                </b-checkbox>
              </div>
              @endforeach
            </b-tab-item> <!--end first tab-->


            <b-tab-item label="Boys"> <!--second tab-->

              @foreach ($children as $child)

                <!--loop around children with gender = 'man'-->

              @endforeach

            </b-tab-item> <!--end second tab-->

            <b-tab-item label="Girls"> <!--third tab-->
              @foreach ($children as $child)

                <!--loop around children with gender = 'man'-->

              @endforeach
            </b-tab-item><!--end third tab-->
          </b-tabs>

Thanks!

19 Apr
10 months ago

Ibe started a new conversation Data Showing Twice

Hi there, I am having a problem with my data... somewhere its looping my data twice because in my view I get the same actone two times. I can't figure out where the problem is..Can someone help please?

The controller

public function show($id)
    {
      $child = Child::find($id);


      // Define a Closure that will apply grouping to each Collection.

   $allActs = $child->actone->toBase()
   ->merge($child->acttwo->toBase())
   ->merge($child->actthree->toBase())
   ->groupBy(function ($act) {
           return $act->created_at->toDateString();
   });

      $next = Child::where('id', '<', $child->id)->orderBy('id', 'desc')->first();
      $previous = Child::where('id', '>', $child->id)->first();
      return view('admin.children.show', compact('child', 'allActs'))->with('next', $next)->with('previous', $previous);
    }

show.blade.php:

@foreach ($allActs as $date => $acts)
<strong>{{ $date }}</strong>

    @foreach($acts as $act)
    @php
        $viewName = (new ReflectionClass($act))->getShortName();
    @endphp

    @include("admin.activities.partials.{$viewName}")
    @endforeach
@endforeach 

partials/actone.blade.php: (for each act)

<?php foreach ($child->actone as $actone): ?>
  <h1>ETEN</h1>

  <td>{{$actone->category}}</td>
  <td>{{$actone->time}}</td>
  <td>{{$actone->name}}</td>
  <td>{{$actone->rating}}</td>
  <td>{{$actone->comment}}</td>

<?php endforeach; ?>

Thanks!!

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus Do you maybe have another solution? Im still struggling with this.. sorry :(

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus Do you maybe have another solution? Im still struggling with this.. sorry :(

18 Apr
10 months ago

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus How can I check this? (sorry im new..) But its difficult to explain what im getting in my view because I am confused of what data im getting back... But i'll give it a try: So I think that my data is looping 2x somewheren... -> If I start 'fresh' and add a new activity (lets say actone), it gets displayed under the correct date. But then when I add another actone, this gets displayed under the correct date, but then each acts gets displayed 2 times... Then this is what im getting in my view: http://prntscr.com/j73dca

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus Hi there, it kinda worked... So I tried it this way with partials, but the strange thing is that all acts display under the correct date, but it always display two times?! and I can't figure out why... http://prntscr.com/j6zc6c

So what I have:

The controller

public function show($id)
    {
      $child = Child::find($id);


      // Define a Closure that will apply grouping to each Collection.

   $allActs = $child->actone->toBase()
   ->merge($child->acttwo->toBase())
   ->merge($child->actthree->toBase())
   ->groupBy(function ($act) {
           return $act->created_at->toDateString();
   });

      $next = Child::where('id', '<', $child->id)->orderBy('id', 'desc')->first();
      $previous = Child::where('id', '>', $child->id)->first();
      return view('admin.children.show', compact('child', 'allActs'))->with('next', $next)->with('previous', $previous);
    }

show.blade.php:

@foreach ($allActs as $date => $acts)
<strong>{{ $date }}</strong>

    @foreach($acts as $act)
    @php
        $viewName = (new ReflectionClass($act))->getShortName();
    @endphp

    @include("admin.activities.partials.{$viewName}")
    @endforeach
@endforeach 

partials/actone.blade.php: (for each act)

<?php foreach ($child->actone as $actone): ?>
  <h1>ETEN</h1>

  <td>{{$actone->category}}</td>
  <td>{{$actone->time}}</td>
  <td>{{$actone->name}}</td>
  <td>{{$actone->rating}}</td>
  <td>{{$actone->comment}}</td>

<?php endforeach; ?>

Ibe left a reply on How To Group Multiple Tables Under The Same Date?

@tykus thanks, taking a look at it :)

Ibe left a reply on How To Group Multiple Tables Under The Same Date?

@tykus yh...but I still couldn't get it to work.. :(

Ibe started a new conversation How To Group Multiple Tables Under The Same Date?

Hi there, does anyone know how to sort data per day from multiple tables?

So I have multiple tables (actone, acttwo, actthree,...). Each one of them contains the timestamps with the created_at. How can I group actone, acttwo, actthree,... under the same date? Can anyone help please?

How I would like my view: https://prnt.sc/j6f73w

ChildController:

public function show($id)
    {
      $child = Child::find($id);

      return view('admin.children.show')->withChild($child);
    }

Show.blade.php:

<?php foreach ($child->actone as $actone): ?>

          <td>{{$actone->category}}</td>
          <td>{{$actone->time}}</td>
          <td>{{$actone->name}}</td>
          <td>{{$actone->rating}}</td>
          <td>{{$actone->comment}}</td>
      <td>{{$actone->created_at}}</td>

        <?php endforeach; ?>


        <?php foreach ($child->acttwo as $acttwo): ?>

          <td>{{$acttwo->time_from}}</td>
          <td>{{$acttwo->time_to}}</td>
          <td>{{$acttwo->rating}}</td>
          <td>{{$acttwo->comment}}</td>
      <td>{{$acttwo->created_at}}</td>

        <?php endforeach; ?>

        <?php foreach ($child->actthree as $actthree): ?>

          <h1>{{$actthree->medication}}</h1>
          <h1>{{$actthree->time}}</h1>
          <h1>{{$actthree->prescription}}</h1>
          <h1>{{$actthree->comment}}</h1>
      <td>{{$actthree->created_at}}</td>

        <?php endforeach; ?>
    
    ...

Thanks!!

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus Could you please take another look at this please? Your solutions seem to work very wel.. thanks

17 Apr
10 months ago

Ibe started a new conversation How To Group Tables Under The Same Date

Hi there, does anyone know how to sort data per day from multiple tables?

So I have multiple tables (actone, acttwo, actthree,...). Each one of them contains the timestamps with the created_at. How can I group actone, acttwo, actthree,... under the same date? Can anyone help please?

How I would like my view: https://prnt.sc/j6f73w

ChildController:

public function show($id)
    {
      $child = Child::find($id);

      return view('admin.children.show')->withChild($child);
    }

Show.blade.php:

<?php foreach ($child->actone as $actone): ?>

          <td>{{$actone->category}}</td>
          <td>{{$actone->time}}</td>
          <td>{{$actone->name}}</td>
          <td>{{$actone->rating}}</td>
          <td>{{$actone->comment}}</td>
      <td>{{$actone->created_at}}</td>

        <?php endforeach; ?>


        <?php foreach ($child->acttwo as $acttwo): ?>

          <td>{{$acttwo->time_from}}</td>
          <td>{{$acttwo->time_to}}</td>
          <td>{{$acttwo->rating}}</td>
          <td>{{$acttwo->comment}}</td>
      <td>{{$acttwo->created_at}}</td>

        <?php endforeach; ?>

        <?php foreach ($child->actthree as $actthree): ?>

          <h1>{{$actthree->medication}}</h1>
          <h1>{{$actthree->time}}</h1>
          <h1>{{$actthree->prescription}}</h1>
          <h1>{{$actthree->comment}}</h1>
      <td>{{$actthree->created_at}}</td>

        <?php endforeach; ?>
    
    ...

Thanks!!

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus Im sorry.. so yeah I want all the actone, acttwo and actthree under the same date. They have different properties

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus It kinda worked... but this is what im getting in my view: https://prnt.sc/j6hp23

So it sorts well on data, but if the date of actone is the same as acttwo, it doesn't show under the same label.. Do you know how to change it?

I tried to add the acttwo like this:

@foreach ($groupedActone as $date => $actones)
    <br>
    {{ $date }}
    <br>


    @foreach($actones as $actone)
    <strong>eten</strong>
        <tr>
            <td>{{$actone->category}}</td>
            <td>{{$actone->time}}</td>
            <td>{{$actone->name}}</td>
            <td>{{$actone->rating}}</td>
            <td>{{$actone->comment}}</td>
        </tr>
    @endforeach


@endforeach


@foreach ($groupedActtwo as $date => $acttwos)
  <br>
    {{ $date }}
  <br>

    @foreach($acttwos as $acttwo)
    <strong>slapen</strong>
        <tr>
            <td>{{$actone->category}}</td>
            <td>{{$actone->time}}</td>
            <td>{{$actone->name}}</td>
            <td>{{$actone->rating}}</td>
            <td>{{$actone->comment}}</td>
            <td>{{$actone->created_at}}</td>
        </tr>
    @endforeach


@endforeach 

Ibe left a reply on Show Data Per Day With Multiple Tables?

@tykus Getting error.. toDateFormat does not work.. http://prntscr.com/j6hgs4

Ibe left a reply on How To Show Items Per Day (created_at)

@rin4ik I forgot it this time... srry @tykus I am having another problem around this... Could you take a look at it please? Maybe you know the solution :) https://laracasts.com/discuss/channels/laravel/show-data-per-day-with-multiple-tables