pickab00

pickab00

Member Since 1 Year Ago

Experience Points 9,230
Experience Level 2

770 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 2
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.

14 Apr
1 week ago

pickab00 left a reply on Extend Date To 3 More Hours Where Post = Today's Post

@BOBBYBOUWMANN - $start = Carbon::now()->startOfDay()->addHours(3); $end = Carbon::now()->endOfDay()->addHours(3);

This bit is exaactly what I needed. So now I can do this:

$start = Carbon::now()->startOfDay();
$end = Carbon::now()->endOfDay()->addHours(3);

$reservations = Reservation::whereBetween('reservation_made_on', [$start, $end])->get();

So now it will show all the reservations which were made for today and keep them till tomorrow 3AM (bacuse of 3 hours added). But my question is this. Will it collapse with the todays data? I mean if it is 3AM, it will show tomorrows data and todays data right? So is it better to do

$start = Carbon::now()->startOfDay()->addHours(3);
$end = Carbon::now()->endOfDay()->addHours(3);

So that it displays from 3AM to 3AM? So it will not show 2 days data at once (2 days being today and tomorrows) Hope I am making sense here

pickab00 started a new conversation Extend Date To 3 More Hours Where Post = Today's Post

I know the title is a bit confusing. I myself am trying to make sense of it. Basically I am using Carbon to get the posts for today and this is how it looks like.

$array = Reservation::whereDate('reservation_made_on', Carbon::today())->get();

So with this, I am getting the reservations made for today (if any). Now that means that the reservations will not be visible after 12:00 AM/24:00. But I want it to be visible till 03:00 AM. So basically its tomorrow and no longer today. How can I achieve this.

pickab00 left a reply on Failed To Parse Time String (04-14-2019 07:30) At Position 0 (0)

@BOBBYBOUWMANN - I actually do have a question. Should I open a new post?

pickab00 left a reply on Failed To Parse Time String (04-14-2019 07:30) At Position 0 (0)

@BOBBYBOUWMANN - This was a really good explanation. Thank you sir. I will accept this as best answer as soon as I get back on my PC. On mobile it gives me 404 for some reason.

pickab00 started a new conversation Failed To Parse Time String (04-14-2019 07:30) At Position 0 (0)

My carbon is returning this error

DateTime::__construct(): Failed to parse time string (04-14-2019 07:30) at position 0 (0): Unexpected character

But I do not see any unexpected characters

here is the code

$parsed_date = $date; //this return   04-14-2019
    $parsed_time = $time->time; //this returns   07:30

$parse_reservation_date = Carbon::parse($parsed_date. ' ' .$parsed_time)->format('Y-m-d H:i:s:u');

return $parse_reservation_date ;
13 Apr
1 week ago

pickab00 started a new conversation Laravel Ajax If First And Second Select Equal To

So I have two select tags with options. Now so far I have a return value from my select tag if it is equal to a specific value. To put it in to perspective here is my ajax

function checkFreeMeal() {


    var url_origin   = window.location.origin;

    $('#existing_guest_selector').on('change', function() {

        var guestID = this.value;

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            type: "GET",
            url: url_origin + '/restaurant-reservations/check-free-meal/' + guestID,

            statusCode: {
                500: function() {
                    $('.something-went-wrong').text('err');
                }
            },
            success: function(data) {
                if (data == 1){
                    $('.free-meal').prop('checked', true);
                }if(data == 0){
                    $('.free-meal').prop('checked', false);
                }
            }
        });

    });

}

My guest ID is coming from my select option value and it is sending to URL which expects a parameter which is the guest ID.

Now I have another Select field which I would Like to use to check if the result is 1 or 0. I want to first check if the guest id returns 1. And later check if the meal plan id returns 1. If they both return 1 from a controller, do something. Currently as mentioned on the code above, My route/URL expects one param and one select change. How can I check two select change and pass those two ID's (guest ID and meal plan ID) to the route? I can write the controller from there. I just want to know How I can pass two select values in to one ajax/route. So guest on change and meal plan on change, pass two id's to the url (something like restaurant-reservations/check-free-meal/' + guestID + '/' + mealPlanID).

05 Apr
2 weeks ago

pickab00 left a reply on Scheduling SMS Job

@SNAPEY - A million thanks to you snapey. I now have a solid understanding of how queues, scheduler and jobs works. I created an Artisan command and just input my conditions in it. Here.

$pendingMinatenance = Maintenance::with('maintenancedepartment')->with('area')->where('created_at', '<', now()->subMinutes(120))->where('sms_sent', null)->get();

    if ($pendingMinatenance->count() > 0){

        foreach($pendingMinatenance as $pendings){

            
    //sms sending code which is really long so I deleted it.

            $pendings->sms_sent = 1;
            $pendings->update();

        }

    }

And finally I used task scheduler (because I am on windows) and called artisan command every 10 minutes. Can you please judge the code above though. That would help me improve a lot

Once again, thank you!

pickab00 left a reply on Scheduling SMS Job

@SNAPEY - Sorry for all the replies.

If I were to use Scheduler and do,

$stuckJobs = Process::where('completed', false)->where('created_at', '<', now()->subMinutes(120))->get();

Than that means that It will keep sending sms to the users which is 2 hours old. So the next 10 minutes will send another sms to the same user about the same data again. It will be repetitive. But to encounter that, I can put a field which says, sent_sms and set it to 1 or something. But I really do not want to create another col in my table. Unless my proposed method of Job delay and comaprison does not work. So what do you think Snapey? My idea of Jobs or Scheduler with a sms_sent or something like that?

pickab00 left a reply on Scheduling SMS Job

@SNAPEY - In my opinion, If I understand the concept right, then Job is better isn't it?

I mean I can simply delay the job to 2 hours and send it to my job class. Now my job class will check if the delayed job is still status pending. If so, then send SMS. But that made me think. If I delay a job to 2 hours, and I insert a new record, wouldn't that be delayed to 2 hours too? Would it create a conflict or something? How does that work

pickab00 left a reply on Scheduling SMS Job

@SNAPEY - I also have another question. Assuming that I dispatched 5 jobs in the past 5 minutes, and delayed them each for 2 hours with a condition which says if they have not being processed, where are the jobs stored till then? I am still getting used to this concept. How do they work exactly?

And if I dispatch the job, can I write the condition inside the job like this?

$time = Carbon::now()->subHour(3);

if($myInsert->created_at <=  $time && $myInsert->status == 0  ){
    //then send sms
}

So this will be my job correct? So I delay it from my controller method which will look something like this.

SendSMS::dispatch($myInsert)
            ->delay(now()->addMinutes(120));

So is this how it will be done? If I am delaying the job, I don't need to check if the time comparison do I? If I understand this correct, now my store() method will delay and send a job in 2 hours after creation and after it goes to the SendSMS job, it will check if the job is still pending. If it is pending, send sms. So I don't really need the time (3 hours) comparison in my Job SendSMS class do I?

And most importantly, where are the jobs stored if I am delaying them for 2 hours. How does that work

pickab00 left a reply on How To Check If It Has Been Two Hours Since The Created Time Using Carbon

@SNAPEY - Yes I know sorry this is to test if my conditions and everything are working fine before I finalize the code

pickab00 left a reply on Scheduling SMS Job

@SNAPEY - Snapey what about task scheduling? Can I create a task and schedule it to check every 1 hour or so and if the condition inside it matches, do something like send an email or sms. I am trying to send an SMS to departments where the jobs are incomplete and has been more than 2 hours. So what would be easier and better? I have never done this so pardon me if I sound like a newbie with scheduling and jobs. Basically I want to check for any records which is older than 2 hours every 1 hour (or minutes) and send sms to the department mobile and notify them of the job not completed. And I am on windows environment not linux. So which would be better? Jobs or Task Scheduling?

pickab00 left a reply on How To Check If It Has Been Two Hours Since The Created Time Using Carbon

@SNAPEY - In a controller to compare the current date with the date created. I want to schedule a job so I want to check if the time is greater than or equal to 3 hours

@tray2 What method would do good? diffForHumans or this:

$test = Reservation::where('created_at','<=',$time)->first();

    return $test;
//I want a collection but for testing purposes first()

Is this better or doing a comparison with diffForHumans?

pickab00 started a new conversation How To Check If It Has Been Two Hours Since The Created Time Using Carbon

How can I check if it has been 2 hours from created_at using carbon. I am unable to find in docs

pickab00 started a new conversation Scheduling SMS Job

Hello. I have the code and everything set up to send sms upon adding the data. So what I had in mind was to send an sms after the 'created_at' has been 1 hour. So after 1 hour of adding, send, do something. How is this possible? I am just simply adding a data and I want to something after 1 hour from data add time. Thanks!

03 Apr
3 weeks ago

pickab00 started a new conversation Pivot Table Not Getting Relationship

I have two tables. One is users and the other is menus. They have a table menu_user which is the pivot table and here is the relationship.

class Menu extends Model
{

        use SoftDeletes;

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

}

class User extends Model
{

        use SoftDeletes;

        public function menus(){
        return $this->belongsToMany('App\Menu');
    }

}

And this is what I am trying in my controller:

$test = Auth::user()->with(['menus' => function($q){
        $q->with('menuroutes');
    }])->get();
//menuroutes is related to the menu table. menu routes belongs to menu and menu has many menuroutes.

    foreach ($test->menus as $menus){
        return $menus;
    }

    return $test;

Basically I want to take the menus belonging to the auth user but it is giving me this error.

"Property [menus] does not exist on this collection instance."

Thanks

02 Apr
3 weeks ago

pickab00 left a reply on Write Middleware To Deny Access To Routes

@LOSTDREAMER_NL - This gives me 403 with every URL now

pickab00 left a reply on Write Middleware To Deny Access To Routes

@LOSTDREAMER_NL - Basically anything which falls behind the defined link inside the table gives me 403. So how can I tell that if the /restaurant-reservations/reservation is accessible, then, /restaurant-reservations/reservation. But if the /user-management is not accessible, then don't allow /user-management/1/edit

sorry if this is complicating

pickab00 left a reply on Write Middleware To Deny Access To Routes

@LOSTDREAMER_NL - This worked but the problem now is this.

The links are given like so...

/reservations/create /reservations/1/edit /user-management

So the route is something.io/reservations/create. This works as intended if the user does not have the menu item. But when I go to /user-management (which is outside of the reservations route group), and go to /user-management/1/edit it gives me 403

pickab00 started a new conversation Write Middleware To Deny Access To Routes

So in my laravel app I can menu items to each user. It works like tags. A pivot table handles belongsToMany relationship on both the tables (users table and menus table). Now the menu table has routes, name, icon etc. This acts as the menu items displayed on the left of the app. What I want to achieve is to be able to deny access to a route if the user does not have that menu item. So far what I have is this code in a middleware.

$auth_menu = User::with(['menus' => function($q){
            $q->whereIn('type', [1, 3])->orderBy('menu_index', 'asc');
        }])->findOrFail($auth->id);

So what that does is, it takes the authenticated user, and finds the user and get the related menu items to that user. Now how can I tell laravel to deny access to that route or abort to 404 if the user does not have a menu item. I want to do this because even though menu items are not displayed, they can still access from url

pickab00 left a reply on Getting 500 Error JQuery

@SNAPEY - It works as intended. It either returns 0 or 1 depending on the logic. I can not reproduce the error when I directly access the url with an ID

pickab00 started a new conversation Question About Base Controller

I wanted to share a variable with all my views so I went on ahead and used my Service provider boot() method to share my variable with all my views using View::share. But the problem was, I had to take the auth user information and as the service provider is loaded before, it returns null.

So I went on ahead and tried this.

public function __construct()
{
    $this->middleware(function ($request, $next) {

        $auth = Auth::user();

        $auth_menu = User::with('menus')->findOrFail($auth->id);

        view()->share('auth_menu', $auth_menu);

        return $next($request);
    });

}

This is inside of my Controller. As in the main controller which extends to base controller and I wanted to know if this method is

A. Safe? B. Good practice?

I did try to get it in to a middleware

Now the second thing I did was to make a middleware ShareMenuVariable:

public function handle($request, Closure $next) {

    $auth = Auth::user();

    $auth_menu = User::with('menus')->findOrFail($auth->id);

    view()->share('auth_menu', $auth_menu);

    return $next($request);
}

And in my kernel I called it in my web group \App\Http\Middleware\ShareMenuVariable::class, so it will always run in web routes.

So which method is better/safe/best practice and which method should I be using and why?

pickab00 left a reply on Getting 500 Error JQuery

@SNAPEY - Yes there is no mention of any errors of 500 or routing errors or GET errors for that specific controller or block

01 Apr
3 weeks ago

pickab00 left a reply on Getting 500 Error JQuery

@SNAPEY - Ok so here is what I tried to do now.

I tried to give var guestID = 1 manually (because that exists in table and is valid). But I am still getting the error. Except, the error is GET http://test.io/reservations/get-preference/1 500 (Internal Server Error). And network shows:

{
    "message": "Server Error"
}{
    "message": "Server Error"
}

Thats all the info there. And like I mentioned before, it only happens on dev mode with clear cache

pickab00 left a reply on [Deleted]

@BOBBYBOUWMANN - Shoot. I am so sorry about this post. I wrote this about an hour ago and I didn't post this until I figured out what was wrong. I accidentally posted this and edited this with [deleted]. Hats off to you you are really fast as I did not even take a second to delete. They really should put a delete function. This is embarrassing. I'm really sorry about this. The issue was that I was calling the change() on the selector. Thanks for the reply!

pickab00 left a reply on Getting 500 Error JQuery

@SNAPEY - Snapey. I am not passing undefined. I checked browser inspected the element and the data-id is there. This is bizarre. Network shows no unusual behavior and I can assure you that the DOM element (data-id span) is being loaded correctly with the correct value. Yet I am still running in to this problem. I was working at office today with the same issue and I came back home and the issue still persists. So it must be a code related issue? Nothing related to any server versions or applications I am using (that was my speculation).

pickab00 started a new conversation Can Not Uncheck Checkbox After Checking Using Jquery/Ajax

So I have a checkbox which is being checked after a certain Jquery/Ajax is run. Here is the ajax:

//This is wrapped in document ready
function checkFreeMeal() {


    var url_origin   = window.location.origin;

    $('#existing_guest_selector').on('change', function() {

        var guestID = this.value;

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            type: "GET",
            url: url_origin + '/restaurant-reservations/check-free-meal/' + guestID,

            statusCode: {
                500: function() {
                    $('.something-went-wrong').text('THERE IS SOMETHING WRONG. CALL THE DEV. WHICH IS ME OBVIOUSLY');
                }
            },
            success: function(data) {
                if (data == 1){
                    $('.free-meal').prop('checked', true); //This is the bit I am having trouble with
                }if(data == 0){
                    $('.free-meal').prop('checked', false);
                }
            }
        });

    });

}

checkFreeMeal();

And here is the .free-meal:

<div class="checkbox checkbox-css">
                <input type="checkbox" id="cssCheckbox33" class="free-meal" name="free_meal" value="1" />
                <label for="cssCheckbox33">Free Meal</label>
            </div>

Now whats happening for me is that once all conditions applies and the data is equal to 1, checkbox is checked but as soon as I uncheck it, it checks back again automatically. this happens when only the check true is inside ajax. How can I resolve this and be able to untick it if I want to?

pickab00 left a reply on Getting 500 Error JQuery

@CRONIX - Oh sorry I forgot to mention that. Yes it is in dom ready event. Yes I inspected it and it has the value correctly.

@tray2 here is my controller:

public function getPax($id) {

        $getPax = GuestPax::where('reservation_id', $id)->get();

        return $getPax;

    }

It is just returning the variable which has all the jsons. That's all its doing after looking through the db. Other than that, the element is taking the value correctly. Whats wierd is this happens only when I have dev open. And dev has clear cache. Could it be that my script is loaded before DOM elements (and by that I mean the span holding data-id). But even that is not possible as it is all the way down of the html and scripts.

pickab00 left a reply on Can Not Use Variable Outside Of If Statement

@CRONIX - Yes I realized that a bit later. That was a mistake on me. Thanks!

pickab00 left a reply on Can Not Use Variable Outside Of If Statement

@FTIERSCH - Actually you are right. It was a dumb mistake on my side. it was not returning 1. That was the whole issue here. Thanks!

pickab00 left a reply on Can Not Use Variable Outside Of If Statement

Ok so for clearence here is the full code sample of what I am trying to do

public function getStuff(Request $request){

//Do some savings of data here $insert = new Stuff; $insert->free_meal = $request->free_meal;

$insert->save();

if ($insert->free_meal == 1){
        $push = 'Guest is also eligible for a Free Meal';
    }

$message = $client->send(
        '0000000000', //This is where the mobile number goes
        $push // Message
    );

}

I hope this clears the confusion. I am trying to take that variable in to something else which is down below.

pickab00 left a reply on Can Not Use Variable Outside Of If Statement

@ARTCORE - This unfortunately does not work

pickab00 left a reply on Can Not Use Variable Outside Of If Statement

@JLRDW - I forgot to paste that code in. Sorry. Here it it.

public function getStuff(Request $request){

//Do some savings of data here
$insert = new Stuff;
$insert->free_meal = $request->free_meal;

$insert->save();

    if ($insert->free_meal == 1){
            $push = 'Guest is also eligible for a Free Meal';
    }

return $push;   

}

So after the save, I am trying to access that data using $insert->free_meal

pickab00 left a reply on Can Not Use Variable Outside Of If Statement

"Undefined variable: push"

Thats all I can Give you really because that is the specific error. Basically I am trying to use the if statements variable outside of the statement but which is inside of the method.

pickab00 left a reply on Getting 500 Error JQuery

Sorry for the late reply @mvd @cronix @luis_carlos

Here is my Ajax:

function managePreference(){

        var guestID = $('#guest_id_holder').data('id');

        $.ajax({
            type: "GET",
            url: url_origin + '/reservations/get-preference/' + guestID,
            dataType: "JSON",
            statusCode: {
                500: function() {
                    $('.something-went-wrong').text('Something is wrong');
                }
            },
            success: function(response){

                var boxp = $('#boxp');
                $(boxp).empty();
                $.each(response, function(index, val) {
                    var name = this.name;
                    var id = this.id;

                    $('<div class="existing-data"><input type="text" name="existing_preference_name[]" class="btn btn-info m-r-5 m-b-5" readonly value="'+name+'"><a href="#" class="delete-existing-preference-data" data-id="'+id+'"><i class="fa fa-times text-danger"></i></a></div>').appendTo(boxp);

                });

            }
        });
    }

    managePreference();

And here is the blade where $('#guest_id_holder').data('id') is coming from:

<span id="guest_id_holder" data-id="{{$edit->guest_id}}"></span>

I am on edit method so I am just passing the $edit var in to the blade and getting the ID of the guest from there. Hope this was enough. Sorry about the mess. I will be refactoring it on the final minified version.

pickab00 started a new conversation Can Not Use Variable Outside Of If Statement

My variable can not be used outside of the if statement. Here is my controller:

public function getStuff(){

    if ($insert->free_meal == 1){
                $push = 'Guest is also eligible for a Free Meal';
        }

    return $push;   

}

It is giving me variable not found

pickab00 started a new conversation Getting 500 Error JQuery

So I have some ajax requests to the server to get some data. I have my clear cache on on my chrome. So It clears cache every time I have my dev box open. And I have noticed that I get 500 server errors when I have my dev open. Could this be because of the cache clear? Is there anyway to find out why this happens? It happens sometimes even though I have my dev options open. Could this be that the script is loading too late? The exact error is as follows.

/somelink/undefined

so that undefined is an ID which is coming from data-id in my blade view (laravel). So obviously undefined is meaning that the data-id is not being pushed. What could be the cause of this? Is this related to clearing cache or how I structured my file links? Ajax is on a separate file which is linked to the page.

pickab00 left a reply on Count Every Fourth Record

@STEREOH - This was exactly what I needed. This worked. Thanks a bunch. Now I know how the operator works and I did my part of the tweaks. Thanks @tykus as well!

pickab00 left a reply on Count Every Fourth Record

@STEREOH - So your previous suggestion was the correct one yes? And this modulo check will ensure that I am getting always the 3rd from every 4th record is that correct? If I understand correctly, thats what’s happening isn’t it? So basically I do not have to check from the last free meal. Just use modulo and if that returns 3 then make this record I am about to add a free meal yes? I am so sorry but this modulo is just confusing me so much. But thank you!

pickab00 left a reply on Count Every Fourth Record

@STEREOH - Yes I do have data and I want to check if the data I am about to enter/save is the 4th data so I can set the meal to free. So That part was not clear for me. tykus method is for displaying every 4th correct? So How can I look through the data, check if there are 3 reservations already and set the one I about about to save to a free meal.

pickab00 left a reply on Count Every Fourth Record

@STEREOH - To put it in to perspective:

Meal 1 - free_meal = 0

Meal 2 - free_meal = 0

Meal 3 - free_meal = 0

Meal 4 - free_meal = 1

Meal 5 - free_meal = 0

Meal 6 - free_meal = 0

Meal 7 - free_meal = 0

Meal 8 - free_meal = 1

pickab00 left a reply on Count Every Fourth Record

@STEREOH - Oh ok I misunderstood it. It's just basically counting.

Can you please explain modulas a bit. I am not quite sure if I understand it correctly.

% 4 == 3 will do what exactly? And does this mean that this will check if the reservation is the 4th reservation after free_meal is 1? Or is it taking the 4th result from the whole result set (lets say 100 results).

What I want is to be able to set the 4th result as a free meal. And once that 4th is set, free_meal will be a boolean which will be set to 1. And from there on, start counting again until the next 4th.

pickab00 left a reply on Count Every Fourth Record

@STEREOH - I am about to sound like a complete doofus here.

What if I had it like this:

$reservation = Reservation::where('guest_id', 1)->get();

What if I am directly taking all from the reservation table and checking the guest id and not your proposed method. I am asking because I have my reservation controller codes arranged in this fashion and I do not want to change it as it will probably confuse me after I have a look at it in about a month or two.

pickab00 left a reply on Count Every Fourth Record

@STEREOH - This is what I want. But here is the thing. I have a field in the table which is free_meal. I want this free meal to be 1 every 4th reservation for that guest. So not just the first 4th. Every 4th reservation. I am trying to understand the logic for that. And a sample code would be:

$reservation = Reservation::where('guest_id', $request->guest_id)->get();

So from there on, How can I check if this is his 4th time or if this is "the next 4th time".

pickab00 left a reply on Count Every Fourth Record

@TYKUS - Thanks a bunch! I just read the docs before I saw this. But I have a very confusing question. At least in my head, I can't think of a way to implement this.

So assuming that I am making a reservation. I am choosing an existing guest. Now the moment I choose the guest from the dropdown, how can I tell that this is his 4th time making a reservation on this restaurant? While I am on the make reservation page.

pickab00 started a new conversation Count Every Fourth Record

So I wanted to display every fourth record taken from the database. Lets say that I want to be able to show an input field for every fourth record in database. what I mean by that is, if this is the 4th record I want to show an input field in my blade. So assuming these are the records I have,

['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']

Now how can I show every 4th record. lets say '4', '8', '12' are the fourth records. And if the current record is a 4th record, I want to show an input field.

Also can I apply some other conditions like all the records which has action as 1. Where action 1, take every 4 records. Sorry I am just bad at explaining this

31 Mar
3 weeks ago

pickab00 left a reply on Edit HasMany Relationship

@SNAPEY - Ok I add that and how would I tell the controller which hidden field belongs to which pax_name[]? there are multiple of those