Pages

Wednesday, November 13, 2019

Create Scheduler CronJob In Laravel and adding cronjob in Linux Crontab

Step 1: Create command in laravel
            php artisan make:command YourCommand

in /app/console/commands
YourCommand.php
     Update line

protected $signature = 'yourcommand:cron';

Create your logic in function

public function handle()
    {
        // Your Code Here

    }



in crontab linux command

sudo crontab -e
press INSERT Button
add command

* * * * * cd /var/www/html/yourproject/ && php artisan schedule:run >> /dev/null 2>&1

save: 
type (:wq)

Add cronjob in Kernel.php

protected function schedule(Schedule $schedule)
    {
        $minutes = env("CRON_INTERVAL",15); 

        // $schedule->command('testcronjob:cron')
                // ->cron($minutes.' * * * *');

        $schedule->command('testcronjob:cron')
                 ->cron('10 * * * *'); //cron('1 * * * *');
        // $schedule->command('testcronjob_half_hour:cron')
        //          ->cron('30 * * * *'); //cron('1 * * * *');
        // $schedule->command('testcronjob_quarter:cron')
        //          ->cron('45 * * * *'); //cron('1 * * * *');
        // $schedule->command('testcronjob_hour:cron')
        //          ->cron('* 1 * * *'); //cron('1 * * * *');
        // $schedule->command('testcronjob_hour_15:cron')
        //          ->cron('15 1 * * *'); //cron('1 * * * *');
        // $schedule->command('testcronjob_hour_30:cron')
        //          ->cron('30 1 * * *'); //cron('1 * * * *');
        // $schedule->call(function () {
        //     Log::info(': Job Run Successfully. ');
        // })->cron(' * * * *');


    }


Monday, November 11, 2019

Get Youtube Playlist Videos Using jQuery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script type="text/javascript">

$(document).ready(function() {
  var youtubeItems = '';
  
    $.get(
      "https://www.googleapis.com/youtube/v3/playlistItems",{
         part : 'contentDetails',
         maxResults: 5,
         playlistId : 'PLvF1USDppY7_TiA7AwGD7OEob9hhQAgLe',                   // Get channel id from youtube -- Settings->Advance Settings
         key: 'AIzaSyBBPbqqUz7-imx-am5uG8DGhhxcf-dzuVU'
         },    // Get youtube data v3 api key from Credential #slack

        function(data) {
          $.each( data.items, function( i, item ) {

          console.log(item);
        if(item.kind == "youtube#playlistItem") {
          youtubeItems += '<iframe width="560" height="315" src="https://www.youtube.com/embed/'+item.contentDetails.videoId+'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
     }
})
       $('.youtube-items').html(youtubeItems);
      }
  );
});

</script>
<div class="youtube-items"></div>




Friday, November 1, 2019

Shopify Newletter Code

{% if section.settings.enable_newsletter %}
                <div class="promo-pop__form">
                    {% form 'customer' %}
                        {{ form.errors | default_errors }}
                        {% if form.posted_successfully? %}
                            {% comment %}Set delay to 0 so form message is visible instanlty{% endcomment %}
                            {%- assign popup_delay = 0 -%}
                            <div class="promo-pop__form-message">
                                <h4 class="promo-pop__form-message__text">{{ 'general.newsletter_form.confirmation' | t }}</h4>
                            </div>
                        {% else %}
                            <div class="promo-pop__fieldset">
                                <input type="hidden" name="contact[tags]" value="newsletter">
                                <input type="email"
                                        name="contact[email]"
                                        id="Email"
                                        class="promo-pop__fieldset-item promo-pop__input"
                                        value="{% if customer %}{{ customer.email }}{% endif %}"
                                        placeholder="{{ 'general.newsletter_form.newsletter_email' | t }}"
                                        autocorrect="off"
                                        autocapitalize="off">
                           
                                <button type="submit" class="c-btn c-btn--primary c-btn--arrow promo-pop__fieldset-item promo-pop__btn" name="commit" id="Subscribe">{{ 'general.newsletter_form.submit' | t }}</button>
                            </div>
                        {% endif %}
                    {% endform %}
                </div>
            {% endif %}