Skip to main content

Posts

Artisan commands in Laravel

Usage of Laravel CLI tool (astisan) This is blogs is specifically for Laravel version 5.2. Artisan provides number of helpful commands for developing project. It is driven by Symfony console component. To use artisan command you should be in your project directory. 1. To see list of all artisan commands       php artisan list 2. To create controller php artisan make:controller YourController or, php artisan make:controller YourController --resource     option "--resource" will generate all REST function (index, store, show, ...) 3. To create migration table php artisan make:migration create_users_table --create=users      It will create a file in /database/migration directory. Use snake case for creating migration so that it will create class like CreateUsersTable.      To migrate tables in to the database use command: php artisan migrate       Rollback migrations: php artisan migrate:rol...

Rule to redirect on login except one-time login in Drupal 7

Redirect to front page on login and when login through one-time-login-url don't redirect to front page We can do this by Rules in Drupal Here is my rules exported code { "rules_smr_redirect_user_logins" : { "LABEL" : "SMR redirect user logins", "PLUGIN" : "reaction rule", "OWNER" : "rules", "REQUIRES" : [ "rules" ], "ON" : { "user_login" : [] }, "IF" : [ { "NOT text_matches" : { "text" : [ "site:current-page:path" ], "match" : "user\/reset" } } ], "DO" : [ { "redirect" : { "url" : "[site:url]" } } ] } } After importing this rule you can change redirect url as per choice.

Create Wordpress custom post type

1. To create custom post type http://www.wpbeginner.com/wp-tutorials/how-to-create-custom-post-types-in-wordpress/ 2. To create different single post template for each post type use single-{post-type name}.php 3. To create different archieve template for each post type use archieve-{post-type name}.php 4. If single page not working for custom post type         Add this to your functions.php:         /* Flush rewrite rules for custom post types. */         add_action( 'after_switch_theme', 'bt_flush_rewrite_rules' );         /* Flush your rewrite rules */         function bt_flush_rewrite_rules() {              flush_rewrite_rules();         }               Then change your theme to a different theme and then set it back again to your custom theme. This will flush the rewrite rule and ...

Adding AJAX to existing node in Drupal 7

To add AJAX to existing node (content type) in Drupal 7 Every Add/Edit node has a form_id. We can use that form_id to alter the form to AJAX handler to any form element. To find form_id of node use Drupal's devel module (dpr() function) or simply just write print_r(form_id) in hook_form_alter() function. To add AJAX handler to node form field write the following code in the hook_form_alter(&$form, &$form_state, $form_id) $form['field_make'][LANGUAGE_NONE]['#ajax'] = array( 'wrapper' => 'trailer-model', 'callback' => 'smr_manage_trailer_populate_models_callback', 'method' => 'replace', 'progress' => array( 'type' => 'throbber', 'message' => "loading", ), ); Here field_make is node form field in which we are adding AJAX. Adding AJAX is same as we do in other ...

How to install Laravel on Ubuntu

To install Laravel you must have install LAMP stack (Linux, Apache2, MySql, and PHP) on your Ubuntu system Install LAMP: If not installed LAMP sudo apt-get install apache2 sudo apt-get install php5 sudo apt-get install mysql-server sudo apt-get install php5-mysql Install PHP extensions Some PHP extensions are necessary to install before installing Laravel 1.  unzip used for the unzip laravel sudo apt-get install unzip 2. Use Composer (which needs CURL) sudo apt-get install curl 3. Use Composer (which downloads via HTTPS, usable only with install Openssl) sudo apt-get install openssl 4. Use Laravel 4 (which needs mcrypt) sudo apt-get install php5-mcrypt Install Composer curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer Activate mod_rewrite sudo a2enmod rewrite sudo service apache2 restart Open the default vhost config file: sudo nano /etc/apache2/sites-available/default Now search for "AllowOv...