Skip to content

Instantly share code, notes, and snippets.

@shahednur
shahednur / 0_reuse_code.js
Created March 13, 2017 06:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Front-end Audit
Use this document as a basis for outlining and planning your front-end build.
You can initially fill this out before the build of your front-end, and then update it as you move through to have an at-a-glance list of information that you can constantly evaluate.
Info
Name, URL, additional site-specific info.
Site: [Site Name]
URL: http://www.example.com
@shahednur
shahednur / vue
Created February 3, 2018 15:20
awesome vue
/* *******************************************************************************************
* GLOBAL CONFIG
* Vue.config is an object containing Vue’s global configurations.
* You can modify its properties listed below before bootstrapping your application.
* https://vuejs.org/v2/api/#Global-Config
* ******************************************************************************************* */
// Configure whether to allow vue-devtools inspection
Vue.config.devtools = true
Route Controller:
//List Products
Route::get('products','ProductController@index');
//List single Product
Route::get('product/{id}','ProductController@show');
//Create new Product
Route::post('product','ProductController@store');
//Update Product
Route::put('product','ProductController@store');
//Delete Product
@shahednur
shahednur / tags.php
Created May 6, 2018 08:11 — forked from jarektkaczyk/tags.php
This is optimization tags for ManyToMany relationship with Post model for attaching not existing tags.
public function store(Post $post)
{
$tags = [];
foreach ((array) request('tags') as $tag_name) {
$tags[] = Tag::firstOrNew(['name' => $tag_name]);
}
// a dla fanow adama wathana o jedna linijke mniej:
//
@shahednur
shahednur / gist:7fae4e199a140ba6fd9d3179ed1d55b5
Created May 6, 2018 08:15 — forked from antonioribeiro/gist:6f7a4c9a1336f798fa65
Add more conditions to your Laravel Relations
public function connections()
{
	$relation = $this
		->belongsToMany(static::class, 'connections', 'requestor_id', 'requested_id')
		->withTimestamps();

	/// delete the already built inner join
	$relation
		->getQuery() // Eloquent\Builder
@shahednur
shahednur / This version is for image and youtube
Last active December 22, 2018 21:36 — forked from jasny/linkify.php
PHP function to turn all URLs in clickable links
Allow display images and youtube video:
CSS class for links .htmllink and images .htmlimg
public function linkify($showimg = 1, $value, $protocols = array('http', 'mail', 'https'), array $attributes = array('target' => '_blank'))
{
// Link attributes
$attr = '';
foreach ($attributes as $key => $val) {
$attr = ' ' . $key . '="' . htmlentities($val) . '"';
}
function getVideoUrl($link){
$data = explode('.mp4', $link);
$decode = urldecode($data[0]);
$linkDownload = array();
$v1080p = $decode.'_hd.mp4';
$v720p = $decode.'_dvd.mp4';
$v360p = $decode.'_fmt1.ogv';
$linkDownload['1080p'] = $v1080p;
$linkDownload['720p'] = $v720p;
$linkDownload['360p'] = $v360p;
@shahednur
shahednur / Nice Route Collections:
Created February 9, 2019 04:18
Laravel Route Group Collections
=========================
======Basic Route========
=========================
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);
Route::match(['get', 'post'], '/',function (){});