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
@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) . '"';
}
@shahednur
shahednur / laravel.js
Created February 9, 2019 05:58 — forked from JeffreyWay/laravel.js
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {
@shahednur
shahednur / Response.php
Created December 10, 2021 13:37 — forked from jeffochoa/Response.php
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@shahednur
shahednur / react-authentication-folder-structure.md
Created February 3, 2022 17:40 — forked from mksglu/react-authentication-folder-structure.md
React JS Authenatication Folder Structure

React JS Authenatication + REST API

Used Packages

  • React JS
  • Redux Thunk
  • Redux Form
  • Redux Logger