Laravel 5.2 – Local query scope not working with cron job / scheduler

By | Laravel

I have observed local query scopes do not work with cron job.

To make it work, I simply scaled down. I put the conditions itself rather than using local query scope.

I know it completely defeats the purpose of creating local query scopes in the first place but at least for now it made the cron job run. Let’s hope this issue gets addressed soon. It is really convenient to use local query scopes.

There is one more issue I found with Laravel cron job.

Issues with Laravel cron job (scheduler)

By | Laravel

Laravel is great at almost everything but there are few areas where it lacks it’s awesomeness.

Problem with cron job (Laravel – 5.2)

I noticed some of the cron jobs were not running. You can use following command to check and run the cron job execution.


1
php artisan schedule:run
Turns out when the cron has withoutOverlapping method chained. It creates a file in the storage/framework folder with the name of schedule-***. 

It appers the existence of this file is used to check whether the cron job is running or not. When the cron job fails for whatever reason the file is not deleted. Since, the file exists the system thinks the cron job is still running and it is not done yet.

This prevents the cron job execution.

For now the solution is to delete the schedule-*** file.

Note: I would also want to add one of my observations: php artisan schedule:run will not show the task(s), if the job only runs on specific day (e.g. everyFriday()) and specific time. The tasks with everyMinute() should run just fine. It makes sense too.

I came across one more issue with Laravel cron job.

What is the ideal slider image size for homepage for various resolutions/breakpoints?

By | CSS, Responsive, Uncategorized

It is essential to use different slider images for desktop and mobiles. Because, the desktop slider image will look very small in terms of length. Any text over slider will have very little space. Hence, for mobile we must use an entirely different image.

Mobile

For mobile I use – 500px x 375px. While writing media queries. You should also consider the landscape resolution (will be discussed soon).

Tablet

The resolution – 960px x 540px seems like a good fit on a tablet.

Desktop

For desktop whatever looks good to your eyes should do it. In one of my recent project, I’ve used – 1900px x 600px

Checkbox

By | Uncategorized

If you have two checkboxes with same name (value should of course be different).

When user submits a form with one selected. In PHP you will get the value as a string for the checked checkbox. Interestingly if user checks both, PHP gives an array and this is without specifying name with an array.

Vuelidate – How to …?

By | Uncategorized

How to check for a field with vuelidate whether it is valid or invalid inside the vue instance?

1
this.$v.call_email_address.$invalid

Form dirty touch and validity check


1
2
3
4
var self = this;
self.$v.$touch();
if (!self.$v.$invalid) {
}

Bootstrap 4 input field validation example


1
2
3
4
5
6
7
8
9
10
<div class="slide-ranger col-md-12">
    <label for="amount" class="control-label sr-only">Loan Amount</label>
    <input type="text" id="range" name="range" class="form-control" v-model="range" :class="{'is-invalid': $v.range.$error, 'is-valid': (!$v.range.$error && $v.range.$dirty)}" @keyUp="$v.range.$touch();">
    <div class="invalid-feedback" :class="($v.range.$error && $v.range.$dirty)">Please enter a valid loan amount
    </div>

                            <p id="slider-range-min"></p>
                            <span style="display: flex;justify-content: center;font-size: 10px;">* use the slider to select the desired loan amount or input manually</span>

                        </div>

Bootstrap 4 select / dropdown validation


1
2
3
4
5
6
7
8
9
10
<div class="form-group col-md-6 mt30">
                            <label class="control-label" for="loan_purpose">What is the purpose of loan?</label>
                            <select id="loan_purpose" name="loan_purpose" class="form-control" v-model="loan_purpose" :class="{'is-invalid': $v.loan_purpose.$error, 'is-valid': (!$v.loan_purpose.$error && $v.loan_purpose.$dirty)}"
                                @change="$v.loan_purpose.$touch();">
                                <option value="">Select purpose of loan</option>
                                <option value="Home Improvement/Renovation">Home Improvement/Renovation</option>
                                <option value="Bill Consolidation">Bill Consolidation</option>
                                <option value="Retail/Purchase">Retail/Purchase</option>
                            </select>
                        </div>

Does Vuelidate offer any emailIf or emailUnless like requiredIf or requiredUnless?

By | Vue, Vuelidate

The answer is no but we still have a problem that we need to solve. What do we do now?

Well, the answer is we don’t need to worry about it. If the condition for required is not met, the email rule should not apply and it doesn’t. Form submits as you would expect (without any errors). However, if user types in the email anyway then Vuelidate expects it to be in a proper format.

Following is just fine.

1
2
3
4
5
6
validations: {
    letter_email_address: {
        required: requiredUnless('isLetter'),
        email
    }
}