Ibe

Experience

2,240

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 3 Lessons Completed
  • 0 Favorites

22nd May, 2018

Ibe started a new conversation Password Updating Problem • 4 weeks ago

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!

14th May, 2018

Ibe left a reply on How To Get Todays Records • 1 month ago

@tykus Thanks!

Ibe started a new conversation How To Get Todays Records • 1 month ago

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

8th May, 2018

Ibe started a new conversation How To Get Today's Rows With Many To Many Relationship • 1 month ago

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!

1st May, 2018

Ibe started a new conversation Showing Todays Records For Each Child • 1 month ago

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? • 1 month ago

@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? • 1 month ago

@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? • 1 month ago

@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? • 1 month ago

@Cronix hmm didn't work either.. thanks

Ibe left a reply on How To Get Only Records Created Today? • 1 month ago

@rin4ik Did nothing.. thanks

Ibe started a new conversation How To Get Only Records Created Today? • 1 month ago

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!

30th April, 2018

Ibe left a reply on Grouping Multiple Tables Under Same Created_at.. • 1 month ago

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

26th April, 2018

Ibe left a reply on Grouping Multiple Tables Under Same Created_at.. • 1 month ago

@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.. • 1 month ago

@burlresearch Thanks I will give this a shot

Ibe started a new conversation Grouping Multiple Tables Under Same Created_at.. • 1 month ago

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!!

24th April, 2018

Ibe left a reply on How To Show Children Based On Gender • 1 month ago

@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 • 1 month ago

@devk getting an error -> http://prntscr.com/j9l7zm

Ibe left a reply on How To Show Children Based On Gender • 1 month ago

@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 • 1 month ago

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!

19th April, 2018

Ibe started a new conversation Data Showing Twice • 2 months ago

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? • 2 months ago

@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? • 2 months ago

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

18th April, 2018

Ibe left a reply on Show Data Per Day With Multiple Tables? • 2 months ago

@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? • 2 months ago

@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? • 2 months ago

@tykus thanks, taking a look at it :)

Ibe left a reply on How To Group Multiple Tables Under The Same Date? • 2 months ago

@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? • 2 months ago

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? • 2 months ago

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

17th April, 2018

Ibe started a new conversation How To Group Tables Under The Same Date • 2 months ago

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? • 2 months ago

@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? • 2 months ago

@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? • 2 months ago

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

Ibe left a reply on How To Show Items Per Day (created_at) • 2 months ago

@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

Ibe started a new conversation Show Data Per Day With Multiple Tables? • 2 months ago

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. I show already all the information for each child... but how do I show my content per day for that child? 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:
      <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 How To Show Items Per Day (created_at) • 2 months ago

@tykus OMG U are amazing sir!! I have been searching so long for this... Really thanks!

Ibe started a new conversation How To Show Items Per Day (created_at) • 2 months ago

Hi there, I don't know how I can sort all the rows that belongs to a date in one section.

I would like to achieve this: http://prntscr.com/j6f73w

So I would love to show the items sorted by date (created_at), does anyone now how please?

ActoneController:

public function index()
    {
        $actones = Actone::orderBy('created_at', 'desc')->paginate(50);
    
        return view('admin.activities.actone.index')->withActones($actones);
    }

index.blade.php

     @foreach ($actones as $actone)
     <div class="card">
       <div class="card-content">

                 <h1>{{$actone->id}}</h1>
                 <h1>{{$actone->category}}</h1>
                 <h1>{{$actone->time}}</h1>
                 <h1>{{$actone->name}}</h1>

                 <h1>{{date('d/m/Y - H:i', strtotime($actone->created_at))}}</td>

       </div>
     </div> <!-- end of .card -->
     @endforeach 

Thanks!!

Ibe started a new conversation How To Make A Boolean Read-unread Label Notification • 2 months ago

Hi there, I don't know how I can make a boolean read-unread label notification.

So what I would like: if there is a new message created for the user, I want to show a little number (span in index) to show that there is a new message... but if the message is checked, I would like it to disappear.

Does anyone know how to do this or how I can complete my code... ?

Here is my code:

MessageController:

public function show($id)
    {
      $user = User::with(['messages' => function ($query){
        $query->where('admin_id', auth()->id());
      }])->findOrFail($id);


      $messages = Message::all();
        return view("admin.messages.show", array('admin' => Auth::user()))->withUser($user);
    }

    public function markAsRead()
     {
      $this->forceFill(['read' => true])->save();
     }

Index.blade.php:

<?php foreach ($users as $user): ?>
        <figure class="image is-32x32">
          <img src="/images/avatars/{{$user->avatar}}" class="rounded-image" alt="Placeholder image">
        </figure>
          <h1>{{ $user->name }}</h1>
          <a class="button is-outlined m-r-5" href="{{route('messages.show', $user->id)}}">View</a>
          <span class="tag is-primary is-small">1</span></p>

     <?php endforeach; ?>

Database:

        $table->increments('id');
            $table->integer('admin_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->text('message');
            $table->boolean('read');
            $table->timestamps();

Thanks!

13th April, 2018

Ibe left a reply on Output String As Icon • 2 months ago

@rin4ik aww my brackets... thanks!!

Ibe started a new conversation Output String As Icon • 2 months ago

Hi there, I don't know how I can change a string value and show it as an icon.. Can someone help me please?

So you can select your gender (man/vrouw), this saves the value 'man' or 'vrouw' into the database. Then in the index page It displays the output..

What I would like is when the output is 'man', I want to show the male icon (instead of the text) and visa versa with 'vrouw'.

Here is my code:

Database:

$table->string('gender');

create.blade.php:

<b-field label="Geslacht:">
              <b-select name="gender" id="gender" placeholder="Selecteer geslacht"  rounded>
                  <option value="Man">Man</option>
                  <option value="Vrouw">Vrouw</option>
                </b-select>
 </b-field>

index.blade.php:

<th>{{$child->gender}}</th>

This is what I tried in my index:

@if ($child->gender == man)
          <span class="icon">
            <i class="fa fa-mars"></i>
          </span>
    @else ($child->gender == vrouw)
          <span class="icon">
            <i class="fa fa-venus"></i>
          </span>
 @endif

Thanks!

12th April, 2018

Ibe left a reply on How To Get Last Characters Of String • 2 months ago

@Cronix @tykus Awesome thanks!! Works both fine!

Ibe started a new conversation How To Get Last Characters Of String • 2 months ago

Hi there, I don't how I can get the last characters of my string.

What I am making is a read more button, in the first part it gets the characters from 0 to 100 (works fine), but then in the second part I want all the characters from 100 till the end of the string... Does someone know how to please?

 <span>{{substr($calendar->details, 0, 100)}}{{ strlen($calendar->details) > 100 ? "..." : ""}} </span>
  <div>
    <span id="text">
      here all the text after 100 charachters
    </span>
  </div>
  <div class="btn-container">
    <button id="toggle">Read More</button>
  </div>

Thanks!

4th April, 2018

Ibe left a reply on How To Order Users With Last Added Messages On Top? • 2 months ago

@rin4ik aww okay, thanks anyway!

Ibe started a new conversation How To Order Users With Last Added Messages On Top? • 2 months ago

Hi there, I don't know how to show users in order of their last created message... Sorth of an inbox style where the user you last spoke to appears on top (first).

MessageController:

public function index()
    {
      $users = User::all();
      return view('admin.messages.index')->withUsers($users);
    }

User model:

public function messages()
{
  return $this->hasMany('App\Message')->latest();
}

Messages model:

public function user()
  {
    return $this->belongsTo('App\User');
  }

Table:

            $table->increments('id');
            $table->integer('admin_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->text('message');
            $table->timestamps();

index.blade.php

 <?php foreach ($users as $user): ?>
       @if($user->messages->count())
        <figure class="image is-32x32">
          <img src="/images/avatars/{{$user->avatar}}" class="rounded-image" alt="Placeholder image">
        </figure>
          <h1>{{ $user->name }}</h1>
          <a class="button is-outlined m-r-5" href="{{route('messages.show', $user->id)}}">View</a>
        @endif
     <?php endforeach; ?>

Route:

Route::resource('/messages', 'MessageController');

So the index now shows all the users, but I would like those users in order of the last message.. Someone knows how to do this please?

Thank!

Ibe left a reply on Only Show Users That Have Messages • 2 months ago

@rin4ik I have another question.. Do you how I can show the user first with a last added message?

Ibe left a reply on Only Show Users That Have Messages • 2 months ago

Wow that easy! Thanks man!!

Ibe started a new conversation Only Show Users That Have Messages • 2 months ago

Hi there, I was wondering how I could change my controller and blade so it only shows only users that have messages.

Problem: I get all the users in my blade..

controller:

public function index()
    {
      $users = User::all();
      return view('admin.messages.index')->withUsers($users);
    }

blade:

<?php foreach ($users as $user): ?>
       <figure class="image is-32x32">
         <img src="/images/avatars/{{$user->avatar}}" class="rounded-image" alt="Placeholder image">
       </figure>
       <h1>{{ $user->name }}</h1>
        <a class="button is-outlined m-r-5" href="{{route('messages.show', $user->id)}}">View</a>

  <?php endforeach; ?>

In my messages table I store the user_id.

So what I would love is when the count of the messages is 0, the user doesn't show.. Anyone know how to do this?

Thanks!

3rd April, 2018

Ibe left a reply on Problem With If Else Structure For Messages... • 2 months ago

@rin4ik Hey I've noticed that my if displays in my admin1 and the else in the admin2 account..? How is that?!?

Ibe left a reply on Problem With If Else Structure For Messages... • 2 months ago

@rin4ik changed the controller, it shows the messages but still not showing the correct name... fml, im so mindfucked Thanks anyway..

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.