Skip to content

Instantly share code, notes, and snippets.

View heryvandoro's full-sized avatar
🏠
I may be slow to respond.

Hery Vandoro heryvandoro

🏠
I may be slow to respond.
View GitHub Profile
@heryvandoro
heryvandoro / currency_lis.php
Created September 13, 2019 05:49 — forked from techguydev/currency_lis.php
Currency list for Laravel seeder
<?php
$currencies = array('code' =>
array('code' =>'AFN' , 'name' => 'Afghani', 'symbol' => '؋' ),
array('code' =>'ALL' , 'name' => 'Lek', 'symbol' => 'Lek' ),
array('code' =>'ANG' , 'name' => 'Netherlands Antillian Guilder', 'symbol' => 'ƒ' ),
array('code' =>'ARS' , 'name' => 'Argentine Peso', 'symbol' => '$' ),
array('code' =>'AUD' , 'name' => 'Australian Dollar', 'symbol' => '$' ),
array('code' =>'AWG' , 'name' => 'Aruban Guilder', 'symbol' => 'ƒ' ),
array('code' =>'AZN' , 'name' => 'Azerbaijanian Manat', 'symbol' => 'ман' ),
array('code' =>'BAM' , 'name' => 'Convertible Marks', 'symbol' => 'KM' ),
let products = [
{ name: "Apple", type: "fruit" },
{ name: "Monitor", type: "computer" },
{ name: "Mango", type: "fruit" },
{ name: "Table", type: "furniture" }
];
console.log(
products.every(product => product.type === "fruit") //false
);
let numbers = [1,3,4,2];
let evenNumber = numbers.find(number => {
return number % 2 == 0;
});
console.log(evenNumber);
/* Output :
4
*/
let peoples = [
{
name : "Andi",
gender : "male"
},
{
name : "Siti",
gender : "female"
},
{
let decimals = [10.2, 11.5, 12.3];
let roundedDecimals = decimals.map(decimal => {
return Math.round(decimal);
});
console.log(roundedDecimals);
/* Output :
[10, 12, 12]
*/
let numbers = [10, 20, 30];
numbers.forEach(number => {
console.log(number);
});
/* Output :
10
20
30
*/
<?php
namespace App\Http\Controllers\API;
class BarangController extends BaseAPIController
{
public function __construct(){
$model_name = "App\Models\Barang";
self::$model = new $model_name;
}
<?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
<?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");
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Category;
class CategoryController extends Controller
{
public function index()