In ‘timezone’ => ‘Asia/Kolkata’ Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add custom CSS to head section in Magento 1 ?Append an…Continue Reading
Snippets List
How to create console command in laravel ?
php artisan make:command CommandNameFile Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add custom CSS to head section in Magento 1 ?Append an…Continue Reading
Show a number in two decimal places in PHP
$number = “105”; echo number_format($number, 2, ‘.’, ”); Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add custom CSS to head section in…Continue Reading
PHP str_replace() Function
replaces all occurrences of search string with a replacement string. Syntax str_replace(find, replace, string, count) find(required) – It specifies the value to find. replace(required) – It specifies the value to replace the value in find. string(required) – it specifies the string to be searched. count(optional) – it is the variable that counts the number of…Continue Reading
How to delete file from public folder in Laravel?
Delete a single File $filename = public_path(‘avatars’).’/photo.jpg’; File::delete($filename); Delete multiple files $data = array($filename1, $filename2); File::delete($data); Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How…Continue Reading
How to run Laravel validation if the field is not empty?
You can simply use sometimes|nullable in the validation rules. It is a best practice for validating optional fields. Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not…Continue Reading
How to add custom CSS to head section in Magento 1 ?
There is two ways to add a custom css to head section in Magento 1 <action method=”addCss”> <stylesheet>css/custom.css</stylesheet> </action> OR <action method=”addItem”> <type>skin_css</type> <name>css/custom.css</name> </action> Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to…Continue Reading
Append an element with fade in effect in jQuery
You can do this by using append function in jQuery as below snippet $(‘#main_conatiner’).append( $(‘<p><img src=”loader.gif”></p>’).hide().fadeIn(2000) ); Or you can use appendTo function as below var html ='<p><img src=”loader.gif”></p>’; $(html).hide().appendTo(“#main_conatiner”).fadeIn(2000); Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from…Continue Reading
jQuery: How to fix div when browser scrolls?
How to fix div when browser scrolls using JQuery Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add custom CSS to head section…Continue Reading
How to select specific columns in laravel eloquent ORM?
Model::select(‘field1′,’field2’)->where(‘type’, ‘post’)->get()
How to remove file preview on the right side of Visual Studio Code Editor
Click on the View menu and look for Toggle Minimap, switch that off.
How to change the default collation of a database?
To Change the entire database’s collation, just run the below query. Or Change collation of just one table Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is…Continue Reading
How to get all days and date for a given month?
This is to get all days and date for choosen month. Just follow the code to display all the dates for a month. $month = “07”; $year = “2018”; $startDate = “01-“.$month.”-“.$year; $startTime = strtotime($startDate); $endTime = strtotime(“+1 month”, $startTime); for($i=$startTime; $i<$endTime; $i+=86400) { $list[] = date(‘Y-m-d-D’, $i); } print_r($list);
Magento1: Get list of all Categories
In Magento there are many ways to get the categories. In this snippet we are showing different method to display categories.
Display All WordPress Posts in One Page with Template Code
How to display all posts in WordPress blog. You may have noticed the posts_per_page set as -1. This do the trick to pull all the posts from WordPress DB. Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public…Continue Reading
Magento 1: How to get the Order Id from Shipping Tracking Id
How to get the Order Id from Shipping Tracking Id. This code would work only if the shipment has created.
How to get all images of product in Magento 1?
Use the following code to get the images for a product in Magento 1. This code snippet will help you get the gallery images for a product in Magento 1. Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from…Continue Reading
Magento – get product id by sku
To get the product id from the SKU in magento1 $sku = 90909; // use your sku $productId = Mage::getModel(“catalog/product”)->getIdBySku( $sku );
How to remove all CSS classes using jQuery?
How to remove all CSS classes for an element instead of removing it individually. Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add…Continue Reading
How to use DB query builder toArray() laravel 5?
DB::table(‘document_attribute_values’)->get()->toArray(); Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add custom CSS to head section in Magento 1 ?Append an element with fade…Continue Reading
How to add new methods to a resource controller in Laravel?
You can just add a route to that method separately, but before you call the resource controller route. Route::get(‘foo/bar’, ‘FooController@bar’); Route::resource(‘foo’, ‘FooController’); Note:Your new methods have to go above the ::resource line Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete…Continue Reading
How to insert multiple rows from a single query using query builder?
It’s really easy to do a bulk insertion of rows in Laravel using arrays. $data = array( array(‘user_id’=>’User 01′, ’email’=> ‘[email protected]’), array(‘user_id’=>’User 02′, ’email’=> ‘[email protected]’), ); DB::table(‘table’)->insert($data); // Query Builder Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder…Continue Reading
How to show all PHP errors and warnings?
You can try the following code at the starting point of your php file. ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1); error_reporting(E_ALL); Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field…Continue Reading
Why you should not use mysql_* functions anymore?
There are several reasons for that 1) it is deprecated 2) It is not included in the PHP 7.0 anymore 3) It is not under active development 4) No support for transactions and stored proceedures Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace()…Continue Reading
What is the difference between ‘git pull’ and ‘git fetch’?
If say simple git pull does a git fetch followed by a git merge. Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add custom CSS to head section…Continue Reading
Best web based easy to use MySQL database management tools?
phpMyAdmin Adminer Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How to add custom CSS to head section in Magento 1 ?Append an element with…Continue Reading
How to check if an element is hidden in jQuery?
If you want to check an element is hidden in on page using jQuery, it’s worth checking below code. $(yourelement).is(“:visible”); Same time you can use the below code for checking the same. $(‘element:hidden’)Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete…Continue Reading
How to get current page URL in PHP?
You can use PHP $SERVER variable for getting current page URL. Being super global variable you will get access to $SERVER in any part of PHP application. Below is a sample script getting the URL of the current page in PHP <?php $uripart = $_SERVER[‘REQUEST_URI’]; $protocol = ((!empty($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] != ‘off’) || $_SERVER[‘SERVER_PORT’] ==…Continue Reading
jQuery hide() and show()
Using jQuery, you can hide and show HTML elements with the hide() and show() methods: $(“#hide_btn”).click(function(){ $(“p”).hide(); }); $(“#show_btn”).click(function(){ $(“p”).show(); });Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the…Continue Reading
How can I refresh a page with javascript?
location.reload(); In jQuery you can trigger an event and call this same function $(‘#divid’).click(function() { location.reload(); });Laravel date set timezoneHow to create console command in laravel ?Show a number in two decimal places in PHPPHP str_replace() FunctionHow to delete file from public folder in Laravel?How to run Laravel validation if the field is not empty?How…Continue Reading