Skip to content

Instantly share code, notes, and snippets.

View xicond's full-sized avatar

xicond

  • Jakarta, Indonesia (ID)
View GitHub Profile
<?php
$schedule->call(function () {
//Hari Ini
$v_now = Order::where('sisa', 0)->where('dp', '>', 0)
->whereHas('nota', function($nota) {
$nota->whereDate('notas.updated_at', Carbon::today());
});
$pengeluaran_now = Pengeluaran::whereDate('updated_at', Carbon::today());
$saldo_now = $v_now->sum('jumlah') - $pengeluaran_now->sum('jlh_uang');
@xicond
xicond / bitbucket-pipelines.yml
Last active March 9, 2022 04:19
Laravel Bitbucket Pipeline Example
# Template PHP Build
# This template allows you to validate your PHP application.
# The workflow allows running tests and code linting on the default branch.
image: php:7.4-alpine
pipelines:
default:
@xicond
xicond / db.txt
Created October 10, 2019 17:19
join-design
MasterReward
- ID (unique ID)
- type of reward
- amount
User
- ID (UserID)
- Name (firstName, lastName)
- birthday
- date register
//repl.it/repls/LimeWholeRedundancy
function solution(record) {
var answer = [];
var dbUser = {};
for (var index in record) {
var commands = record[index].split(' ');
switch(commands[0]) {
@xicond
xicond / News.php
Created May 25, 2018 07:50
Test Arrayable to output readonly
<?php
use yii\base\Arrayable;
use yii\base\ArrayableTrait;
use yii\base\Component;
use yii\helpers\ArrayHelper;
class News extends Component implements Arrayable
{
use ArrayableTrait;
protected $article_title = '';
@xicond
xicond / api.php
Created May 16, 2018 02:49
sample behavior
<?php
use yii\base\Component;
use yii\base\Behavior;
class api extends Components {
}
<?php
namespace namespaces;
abstract class Singleton
{
// an array of instances. this will keep track of objects already created
private static $instances = [];
abstract protected function __construct();
// this function gets called whenever there is a request for a static function
@xicond
xicond / test
Created November 22, 2017 19:40
public function testSlugifyDashSpace() {
$faker = Faker\Factory::create();
$faker->addProvider(new Faker\Provider\Lorem($faker));
$str1 = $faker->word;
$str2 = $faker->word;
$this->assertEquals($str1.' '.$str2, TextHelper::slugifyDashSpace($str1.' '.$str2));
Yii::$app->params['slugifyDashSpace'][Yii::$app->params['projectCode']] = true;
$this->assertEquals($str1.' '.$str2, TextHelper::slugifyDashSpace($str1.'-'.$str2));
}
<?php
namespace app\components;
use Yii;
use yii\base\Exception;
class ApiCached extends ApiWrapper
{
const DEFAULT_CACHE_DURATION = 600;
<?php
namespace app\models;
use Yii;
use yii\db\Expression;
/**
* This is the model class for table "modelA".
*