Skip to content

Instantly share code, notes, and snippets.

View tisuchi's full-sized avatar
🙂
Smile is Sadaqah (righteousness)

Thouhedul Islam tisuchi

🙂
Smile is Sadaqah (righteousness)
View GitHub Profile
@tisuchi
tisuchi / belongs-to-many.sublime-snippet
Created March 23, 2016 09:03 — forked from adamwathan/belongs-to-many.sublime-snippet
Eloquent Relationship snippets for Sublime Text
<snippet>
<content><![CDATA[
public function ${1:relationship}()
{
return \$this->belongsToMany(${1/^(.+)$/(?1\u$1:)/g}::class, {$2:table});
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>belt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> VueJs transition for loading data - larademy.com</title>
</head>
<body>
<div id="app">
@tisuchi
tisuchi / select-whole-text.html
Created June 3, 2017 16:41
Sublime text workflow for everyday
<div>
This is my whole text that I need to select by keyboard in a easy way.
</div>
@tisuchi
tisuchi / laravel-fetch-results-grouped-days-way-1
Created June 30, 2017 07:07
Laravel fetch results grouped by days // larademy.com
$users =DB::table('users')
->select(DB::raw('DATE(created_at) as date'), DB::raw('count(*) as views'))
->groupBy('date')
->get();
@tisuchi
tisuchi / laravel-fetch-results-grouped-days-way-2
Created June 30, 2017 07:13
Laravel fetch results grouped by days | Larademy.com
$users = User::where('created_at', '>=', \Carbon\Carbon::now->subMonth())
->groupBy('date')
->orderBy('date', 'DESC')
->get(array(
DB::raw('Date(created_at) as date'),
DB::raw('COUNT(*) as "views"')
));
@tisuchi
tisuchi / gist:a62aee5188e5b1830d1e1362ab5b81c7
Created September 8, 2017 20:59
declare clean php variable 1
//its a really bad practice
$a = 'Go to school';
$b = 'Go to Market';
$c = 'Buy Items';
$d = 'Finish home task';
//good way to define variables
@tisuchi
tisuchi / number-to-month-PHP.php
Last active September 20, 2017 05:41
Convert number to month name in PHP
<?php
// here, 1 means the first month of Year
$monthNumber = 1; //month in number
//it will return the name of the month
$getMonthName = date('F', mktime(0, 0, 0, $monthNum, 10)); // January
@tisuchi
tisuchi / Daterangepicker.js
Created September 20, 2017 05:49
Change the date format in Daterangepicker - tisuchi.com
<script type="text/javascript">
$('#calendar-field').daterangepicker(
{
locale: {
format: 'YYYY-MM-DD'
},
..... // other properties
},
@tisuchi
tisuchi / laravel-with().php
Last active September 20, 2017 05:53
Example of Laravel with() - tisuchi.com
<?php
$users = User::with('posts')->get();
foreach($users as $user){
$users->posts; // posts is already loaded and no additional DB query is run
}
?>
@tisuchi
tisuchi / laravel-has().php
Last active September 20, 2017 05:56
Example of Laravel has() - tisuchi.com
<?php
$users = User::has('posts')->get();
// only users that have at least one post are contained in the collection