AngularJS tips tricks for beginner
source : http://stackoverflow.com/a/17329630
source : http://stackoverflow.com/a/17816525
source : http://stackoverflow.com/a/20561670
integrasolid AngularJS 0 comments
// find('#id')
angular.element(document.querySelector('#id'))
//find('.classname'), assumes you already have the starting elem to search from
angular.element(elem.querySelector('.classname'))
source : http://stackoverflow.com/a/17329630
//in service
itemsService.loadItems = function (setID) {
$http({
url: 'get-items/'+setID,
method: "POST"
})
.success(function (data, status, headers, config) {
$scope.items = data;
$rootScope.$broadcast('updateItems', data);
})
.error(function (data, status, headers, config) {
$scope.status = status;
});
};
//in controller
$scope.$on("updateItems",function(d){
$scope.items = d;
});
//
source : http://stackoverflow.com/a/17816525
var items = angular.module('items', []);
var text = angular.module('text', []);
var app = angular.module('app', ['items', 'text']);
text.controller('TextController', function ($scope) {
//Controller Code Here
});
items.controller('ItemController', function ($scope) {
//Controller Code Here
});
source : http://stackoverflow.com/a/20561670
integrasolid WooCommerce 0 comments
Add this on your theme functions.php or via a custom plugin
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['shipping']['shipping_phone'] = array(
'label' => __('Phone', 'woocommerce'),
'placeholder' => _x('Phone', 'placeholder', 'woocommerce'),
'required' => false,
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}
/**
* Display field value on the order edit page
*/
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo '<p><strong>'.__('Phone From Checkout Form').':</strong> ' . get_post_meta( $order->id, '_shipping_phone', true ) . '</p>';
}
integrasolid WooCommerce 0 comments
//custom WooCommerce admin action
add_action( 'woocommerce_order_action_ezpocket_finish_pickup', 'process_order_pending_delivery_actions' );
//use $woocommerce->mailer() to send custom email with WooCommerce styling
function process_order_pending_delivery_actions($order)
{
$order_id = $order->ID;
$first_name = $order->billing_first_name;
$last_name = $order->billing_last_name;
$full_name = $first_name.' '.$last_name;
$shipping_address = $order->get_formatted_shipping_address();
$delivery_items = $order->get_items();
$custom_data = get_post_custom($order_id);
$delivery_date = $custom_data['_delivery_time'];
$delivery_date = date_i18n('F d, Y H:i', $delivery_date);
$items_list = array();
foreach ($delivery_items as $key => $item) {
$product_name = $item['name'];
$product_quantity = $item['qty'];
$item_row = '';
$unit = ' unit of ';
if ($item['qty']>1) {
$unit = ' units of ';
}
$item_row = $product_quantity.$unit.$product_name;
$items_list[] = $item_row;
}
global $woocommerce;
$subject = 'Delivery schedule for your items';
$admin_email = get_option( 'admin_email' );
$to = array($admin_email,'[email protected]');
$mailer = $woocommerce->mailer();
$message_body = "<p>Dear $full_name,</p>";
$message_body .= "<p>We will deliver your ordered items on this specific date. Below is the details :</p>";
$message_body .= "<p>Order ID : $email_order_id </p>";
$message_body .= "<p>Your items : </p>";
foreach ($items_list as $key => $item) {
$message_body .= "<p>$item</p>";
}
$message_body .= "<p><h3>Delivery Schedule : $delivery_date</h3></p>";
$message_body .= "<p>Delivery address : </p>";
$message_body .= "<p>$shipping_address</p>";
$message = $mailer->wrap_message($subject, $message_body );
$mailer->send( $to, $subject, $message);
}
integrasolid WooCommerce 0 comments
How to filter order report based on Shop Manager user ID
http://wordpress.stackexchange.com/questions/123586/filter-orders-in-admin-area-based-on-custom-meta
Filter WooCommerce orders by role
Filter WooCommerce report by role
https://wordpress.org/plugins/woocom-role-based-reports/
Filter WooCommerce orders by product
https://wordpress.org/plugins/woocommerce-filter-orders-by-product/
How to build wholesale system with WooCommerce
integrasolid Laravel 0 comments
This is a collection of references for our upcoming Laravel 5.2 video tutorial for beginner!
Bootstrap 3 comments thread layout
http://bootsnipp.com/snippets/featured/comment-posts-layout
Laravel 5 custom helper
http://stackoverflow.com/a/32772686
Eloquent get HasMany realtionship last record
http://alexkaye.co.uk/2015/01/04/eloquent-get-first-last-related-row/
Eloquent HasMany count efficiently
https://softonsofa.com/tweaking-eloquent-relations-how-to-get-hasmany-relation-count-efficiently/
Eloquent relationship
https://daylerees.com/codebright-eloquent-relationships/
Eloquent relationship confusion?
http://laravel-tricks.com/tricks/correctly-using-eloquent-relationships
Eloquent cheat sheet
https://gist.github.com/msurguy/5654552
https://gist.github.com/hassansin/2fb9d72b51860d454316
Laravel Tips Tricks
Laravel Collection Tricks
http://codebyjeff.com/blog/2015/05/stupid-collection-tricks-in-laravel
Reduce repetitive code using Trait
http://stackoverflow.com/a/30365349/417899
Laravel Design Pattern using Service Class and Repository
http://stackoverflow.com/a/18992000
http://stackoverflow.com/a/37015564
Laravel Eloquent tips tricks
http://laragems.com/post/eloquent-cheat-sheet
http://laraveltnt.com/conditional-eloquent-clauses/#more-120
http://terryharvey.co.uk/5-laravel-eloquent-tips-tricks/
http://valentinvannay.com/2016/03/23/laravel-5-useful-tips-notes/
http://webnifier.com/laravel-eloquent-tips-and-tricks/
https://www.ibm.com/developerworks/library/os-php-7oohabits/
integrasolid Laravel 0 comments
Form Validation with Request Class
Easy success and error message with Laracasts Flash provider
Pub Sub pattern with Laravel Event
Cool JS alert with Sweet Alert
Dynamic dependant dropdown using Ajax
AJAX loader with PACE Js
PDF report with DOMPDF
File Upload
Eloquent Polymorphism
Data filter using dropdown and textfield
Eloquent Eager Loading
BaseController
Permission check using Middleware
Automatic session expired checking
Unit Testing
We use Monit to monitor server status. Sometimes MYSQL failed to start and execution failed error is display.
The steps that we use to troubleshoot:
/etc/init.d/mysql stop
/etc/init.d/mysql start
/etc/init.d/mysql: ERROR: The partition with /var/lib/mysql is too full! ... failed!
df -h
ls -l *
To remove all logs file php7.0-fpm-sp.log.1.gz to php7.0-fpm-sp.log.26.gz, use this command
rm file1.*
Example
rm php7.0-fpm-sp.log.*
rm *
sudo ncdu /
integrasolid Laravel 0 comments
How to generate auth login, register bootstrap views
php artisan make:auth
How to change redirect after login
On AuthController.php
protected $redirectTo = 'notices/create';
How to fix no session after redirect using middleware auth
Route::group(['middleware' => ['web']], function () {
//
});
https://laravel.com/docs/5.2/routing#basic-routing
How to use HTML Form Helper LaravelCollective
composer require laravelcollective/html
https://laravelcollective.com/docs/5.2/html
How to add additional method for resource controllers
Route::get('photos/popular', '[email protected]');
Route::resource('photos', 'PhotoController');
https://laravel.com/docs/5.1/controllers
How to clear cache and config cache
php artisan clear:cache php artisan config:cache
How to get current username and email
Migration with table id and timestamp
php artisan make:migration create_notices_table --create=notices
Reference js, css in public folder
Form AJAX
Ajax and JS helper for Laravel
Laravel 5 Form Request with multiple validation rules and unique check on Update
integrasolid AngularJS, IONIC, WordPress 0 comments
https://www.codetutorial.io/use-angularjs-as-wordpress-frontend/
http://code.tutsplus.com/tutorials/introducing-the-wp-rest-api–cms-24533
https://1fix.io/blog/2014/11/05/angularjs-json-api-wp-theme/#more-523
http://dev.imbilal.com/wp-api-front-end/#/posts
https://creatorup.com/ionic-mobile-app-class/
http://scottbolinger.com/ionic-wordpress-app/
http://stackoverflow.com/questions/29665933/ionic-how-can-php-be-used-as-backend-for-ionic-framework
http://learn.ionicframework.com/formulas/backend-data/
https://github.com/michaelbromley/angular-wordpress-seed
https://github.com/angular-app/angular-app
integrasolid Laravel 0 comments
Example 1, using query builder on controller function
public function index()
{
$state = Input::get('state');
$site_name = Input::get('site_name');
$query = DB::table('approvedsites')
->join('ref', 'approvedsites.state', '=', 'ref.code')
->select('approvedsites.*', 'ref.desc1')
;
if (!empty($state)) {
$query = $query->where('state','=',$state);
}
if (!empty($site_name)) {
$query = $query->where('agname','LIKE',"%$site_name%");
}
$approvedsites = $query->get();
//view raw sql query
dd($query->toSql());
dd(DB::getQueryLog());
}
Example 2, using static method on model
//controller function
public function index()
{
$state = Input::get('state');
$site_name = Input::get('site_name');
$filter_data = array('state' => $state,
'site_name' => $site_name
);
$approvedsites = Approvedsite::getAllApprovedSites($filter_data)->get();
//view raw sql query
dd($query->toSql());
dd(DB::getQueryLog());
}
//model function
public static function getAllApprovedSites($filter_data=array())
{
$query = DB::table('approvedsites')
->join('ref', 'approvedsites.state', '=', 'ref.code')
->select('approvedsites.*', 'ref.desc1')
;
if (isset($filter_data['state']) && !empty($filter_data['state'])) {
$state = $filter_data['state'];
$query = $query->where('state','=',$state);
}
if (isset($filter_data['site_name']) && !empty($filter_data['site_name'])) {
$site_name = $filter_data['site_name'];
$query = $query->where('agname','LIKE',"%$site_name%");
}
return $query;
}
Example 3 – Using scope method on model
//controller function
public function index()
{
$state = Input::get('state');
$site_name = Input::get('site_name');
$filter_data = array('state' => $state,
'site_name' => $site_name
);
$approvedsites = Approvedsite::filter($filter_data)->get();
//view raw sql query
dd($query->toSql());
dd(DB::getQueryLog());
}
//model function
public function scopeFilter($query,$filter_data=array())
{
if (isset($filter_data['state']) && !empty($filter_data['state'])) {
$state = $filter_data['state'];
$query->where('state','=',$state);
}
if (isset($filter_data['site_name']) && !empty($filter_data['site_name'])) {
$site_name = $filter_data['site_name'];
$query->where('agname','LIKE',"%$site_name%");
}
return $query;
}