Skip to content

Instantly share code, notes, and snippets.

@RakibSiddiquee
RakibSiddiquee / create_input_slug_initial.html
Last active April 21, 2017 13:12
To create input slug and initial from an input field
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
</head>
<body>
<form action="">
Name: <input type="text" name="name" id="name"/><br/>
@RakibSiddiquee
RakibSiddiquee / jquery-sortable-serialize.html
Last active April 21, 2017 13:14
Jquery sortable and serialze and save it database using php
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Jquery sortable serialize</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<div class="content-wrapper">
@RakibSiddiquee
RakibSiddiquee / autocomplete-from-database.php
Last active May 8, 2017 06:55
Autocomplete an input field from database using jquery
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Jquery sortable serialize</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style>
.ui-widget.ui-widget-content{max-height: 500px; overflow-y: scroll; overflow-x: hidden;}
.item{list-style: none; background: lightgray; padding: 5px; margin: 2px 0; width: 500px; cursor: move;}
@RakibSiddiquee
RakibSiddiquee / replace_array_element.php
Last active April 23, 2017 05:21
When we want to replace an element or some elements of an array with an element or an array of elements
<?php
$arr = [100, 200, 300, 400, 500]; // An array containing some values
$new_arr = [2 => 1001]; // Take a new array with a key where we want to keep the value
array_splice($arr, 2, 1, $new_arr); // array_splice(old_array, position_from_where_to_start, no_of_element_of_new_array, new_array)
print_r($arr);
@RakibSiddiquee
RakibSiddiquee / populate-dropdown.html
Last active May 3, 2017 11:50
Populate one dropdown when select another dropdown. You must include the jquery file top of your code...
// There are two ways...
// No:1.......
$(function() {
$('#category').change(function() {
var cat = $(this).val();
$.get('{{ url("categories") }}', {'cat_id': cat}, function (data) {
$('#subcategory').empty();
$.each(data, function(key, value) {
@RakibSiddiquee
RakibSiddiquee / datetime-difference.php
Created May 14, 2017 09:54
Get the difference between two date or two datetime
<?php
// Date time difference
$dt = date_diff(date_create('2017-01-01 02:20:10'), date_create('2017-02-01 23:23:23'));
var_dump($dt);
// Date difference
$d = date_diff(date_create('2017-01-01'), date_create('2017-02-01'));
var_dump($d);
@RakibSiddiquee
RakibSiddiquee / get-last-7days-data.php
Created May 18, 2017 09:11
Get last 7 days data from database order by relation table's field
<?php
public function test(){
$days = new Carbon();
$bn_contents = BnContent::with('category','subcategory','content_meta')
->leftJoin('bn_content_metas', 'bn_contents.content_id', '=', 'bn_content_metas.content_id')
->where('bn_contents.created_at', '<', $days->subDays(7)->toDateTimeString())
->where('bn_contents.status', 1)->where('bn_contents.deletable', 1)
->orderBy('bn_content_metas.total_hit','desc')->take(5)->get();
return ($bn_contents);
@RakibSiddiquee
RakibSiddiquee / Laravel-Upload-in-cpanel.txt
Created July 18, 2017 12:43
When we upload laravel project in live server or cpanel. We should follow the following instructions...
Clear all view, route, config and cache
Upload the project in live server
After that upload the dot prefixed files in the live server
@RakibSiddiquee
RakibSiddiquee / copyOnclick.html
Created July 31, 2017 08:14
Copy to clipboard by onclick
<!--Pass the url and id in input field-->
<input type="text" value="{{ config('app.url').config('appconfig.contentImagePath').$photo->img_path }}" id="url-{{ $photo->id }}" class="form-control" readonly>
<!--Pass the id in onclick button-->
<button type="button" onclick="copyUrl({{ $photo->id }})" class="btn btn-primary">Copy</button>
<!--The javascript code-->
<script>
function copyUrl(id){
//alert('hello');
@RakibSiddiquee
RakibSiddiquee / BanglaDate.php
Last active August 4, 2017 10:10
Bangla date from english date. First we create a class and include the class in our required page, call the necessary methods and print our date variable.
//make a class...
class BanglaDate
{
private $timestamp; //timestamp as input
private $morning; //when the date will change?
private $engHour; //Current hour of English Date
private $engDate; //Current date of English Date
private $engMonth; //Current month of English Date
private $engYear; //Current year of English Date