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
<button type="submit" value="1" name="frm_button" class="btn btn-primary">Submit</button>
<?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();
<?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();
$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
<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">
@jorgecc
jorgecc / cattable.csv
Created November 11, 2018 02:05
cattable.csv
id_category name
1 premium
2 normal
3 expensive
4 other
@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 / BuyMilk2.php
Created December 9, 2018 18:46
BuyMilk2
<?php
// it is specific for this project
define('INITIAL_STATE',1);
define('DRIVING_TO_BUY_MILK',2);
define('CANCEL_DRIVING',3);
define('PICKING_THE_MILK',4);
define('PAYING_FOR_THE_MILK',5);
define('UNABLE_TO_PURCHASE',6);
define('DRIVE_BACK_HOME',7);
@jorgecc
jorgecc / BuyMilk3.php
Created December 9, 2018 18:48
BuyMilk3
<?php
// database configuration
$smachine->tableJobs="buymilk_jobs";
$smachine->tableJobLogs="buymilk_logs"; // it is optional
$smachine->setDB('localhost',"root","abc.123","statemachinedb");
$smachine->createDbTable(false); // you don't need to create this table every time.
$smachine->loadDBAllJob(); // we load all jobs, including finished ones.
//$smachine->loadDBActiveJobs(); // use this in production, we don't need stopped job every time.