This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sending to sender-client only | |
socket.emit('message', "this is a test"); | |
// sending to all clients, include sender | |
io.emit('message', "this is a test"); | |
// sending to all clients except sender | |
socket.broadcast.emit('message', "this is a test"); | |
// sending to all clients in 'game' room(channel) except sender |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
/** | |
* If the incoming request is an OPTIONS request | |
* we will register a handler for the requested route | |
*/ | |
class CatchAllOptionsRequestsProvider extends ServiceProvider { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Models\Category; | |
class CategoryController extends Controller | |
{ | |
public function index() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use Illuminate\Database\Eloquent\Model; | |
class Category extends Model | |
{ | |
protected $with = ["sub_categories"]; | |
public function sub_categories(){ | |
return $this->hasMany("App\Models\Category", "parent_id", "id"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\API; | |
use Illuminate\Http\Request; | |
use App\Http\Controllers\Controller; | |
use Validator; | |
use App\Helpers\MessagesConstants; | |
class BaseAPIController extends Controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\API; | |
class BarangController extends BaseAPIController | |
{ | |
public function __construct(){ | |
$model_name = "App\Models\Barang"; | |
self::$model = new $model_name; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let numbers = [10, 20, 30]; | |
numbers.forEach(number => { | |
console.log(number); | |
}); | |
/* Output : | |
10 | |
20 | |
30 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let decimals = [10.2, 11.5, 12.3]; | |
let roundedDecimals = decimals.map(decimal => { | |
return Math.round(decimal); | |
}); | |
console.log(roundedDecimals); | |
/* Output : | |
[10, 12, 12] | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let peoples = [ | |
{ | |
name : "Andi", | |
gender : "male" | |
}, | |
{ | |
name : "Siti", | |
gender : "female" | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let numbers = [1,3,4,2]; | |
let evenNumber = numbers.find(number => { | |
return number % 2 == 0; | |
}); | |
console.log(evenNumber); | |
/* Output : | |
4 | |
*/ |
OlderNewer