Skip to content

Instantly share code, notes, and snippets.

View jorgecc's full-sized avatar
🏠
Working from home

Jorge Castro jorgecc

🏠
Working from home
View GitHub Profile
@jorgecc
jorgecc / BuyMilk1.php
Created December 9, 2018 18:42
BuyMilk 1
<?php
/**
* @author Jorge Patricio Castro Castillo <jcastro arroba eftec dot cl>
* @link https://github.com/EFTEC/StateMachineOne
*/
use eftec\statemachineone\Job;
use eftec\statemachineone\StateMachineOne;
use eftec\statemachineone\Transition;
@jorgecc
jorgecc / cattable.csv
Created November 11, 2018 02:05
cattable.csv
id_category name
1 premium
2 normal
3 expensive
4 other
<div class="row">
<div class="col-md-12">
<form class="" method="post" >
<div class="form-group">
<label class="">Name</label>
<input type="text" class="form-control" placeholder="Enter a Product" name="frm_name"
value="{{$product['name']}}">
<small class="text-danger">{{$messages->get('frm_name')->firstError()}}</small>
</div>
<div class="form-group">
$button=$val
->type('integer') // it must be a number
->def(0) // default value is zero
->ifFailThenDefault() // if fails then, the button will be the default value=0
->post('frm_button'); // fetch the value
<?php
include "vendor/autoload.php"; // it is crap, I will explain it later.
include "dao/ProductDao2.php";
// view
$blade=new \eftec\bladeone\BladeOne(__DIR__."/view",__DIR__."/compile");
$blade->setMode(\eftec\bladeone\BladeOne::MODE_DEBUG);
// validation
$val=new \eftec\ValidationOne();
<?php
include "vendor/autoload.php"; // it is crap, I will explain it later.
include "dao/ProductDao.php";
// view
$blade=new \eftec\bladeone\BladeOne(__DIR__."/view",__DIR__."/compile");
$blade->setMode(\eftec\bladeone\BladeOne::MODE_DEBUG);
// persistence
$db=new \eftec\DaoOne("localhost","root","abc.123","bladeonetut1");
$db->connect();
<?php
include "vendor/autoload.php"; // it is crap, I will explain it later.
include "dao/ProductDao.php";
// view
$blade=new \eftec\bladeone\BladeOne(__DIR__."/view",__DIR__."/compile");
$blade->setMode(\eftec\bladeone\BladeOne::MODE_DEBUG);
// persistence
$db=new \eftec\DaoOne("localhost","root","abc.123","bladeonetut1");
$db->connect();
<button type="submit" value="1" name="frm_button" class="btn btn-primary">Submit</button>
<input type="number" name="frm_price" class="form-control" placeholder="Price" value="{{$product['price']}}">
@jorgecc
jorgecc / injection3.php
Created October 4, 2018 00:38
Example of DI
<?php
$obj=new ClassConvertMoneyWithInjection();
echo "converting 300 dollars to euro:<br>";
$obj->setService(new ServiceDollarToEuro());
$obj->example(300);
echo "converting 300 euros to dollar:<br>";
$obj->setService(new ServiceEuroToDollar());
$obj->example(300);