React JS Authenatication + REST API
Used Packages
- React JS
- Redux Thunk
- Redux Form
- Redux Logger
public function getClientIps() | |
{ | |
$clientIps = array(); | |
$ip = $this->server->get('REMOTE_ADDR'); | |
if (!$this->isFromTrustedProxy()) { | |
return array($ip); | |
} | |
if (self::$trustedHeaders[self::HEADER_FORWARDED] && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED])) { | |
$forwardedHeader = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]); | |
preg_match_all('{(for)=("?\[?)([a-z0-9\.:_\-/]*)}', $forwardedHeader, $matches); |
module.exports = { | |
prefix: '', | |
important: false, | |
separator: ':', | |
theme: { | |
screens: { | |
sm: '640px', | |
md: '768px', | |
lg: '1024px', | |
xl: '1280px', |
<?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; |
in database: | |
$table->enum('fruit', ['apple', 'banana', 'cantalope']); | |
in controller's construct: | |
public function __construct() | |
{ | |
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); | |
} | |
how to use this Enum in cotroller: |
/* | |
<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() { |
========================= | |
======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 (){}); |
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; |
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) . '"'; | |
} |
public function connections()
{
$relation = $this
->belongsToMany(static::class, 'connections', 'requestor_id', 'requested_id')
->withTimestamps();
/// delete the already built inner join
$relation
->getQuery() // Eloquent\Builder