Coder Social home page Coder Social logo

sheets's Introduction

atl-framework

Framework MVC for team

Get Started

Composer Download.

$ composer install

Load view

View('layout/header')

Use Route

Main index

$route->get('/','MainController@index');

Route Get

$route->get('/id/{id}', 'MainController@checkRouteGet');

Route Post

$route->post('/validate','MainController@checkRoutePost');

Route validate int

$route->get('/id/{id}', 'MainController@checkRoutePost', array('page' => '\d+'));

Validation Form;

Exemple detail.

use Atl\Validation\Validation;
$validator = new Validation;

$validator->add(
    array(

        // the key is in the form [field]:[label]
        'name:Name' => 'required',

        // you can have multiple rules for the same field
        'email:Your email' => 'required | email',

        // validators can have options
        'message:Your message' => 'required | minlength(10)',

        // and you can overwrite the default error message
        'phone:Phone' => 'regex(/your_regex_here/)(This field must be a valid US phone number)'
    )
);

if ($validator->validate($_POST)) {

    // send notifications to stakeholders
    // save the form data to a database

} else {

    // send the error messages to the view
    $view->set('errors', $validator->getMessages();

}

Session;

Handle session.

// Config file config/app.php
'session' => array( 'status' => true, 'storage' => ''),


 // Use code base
Session()->set('name','Test Session');
echo Session()->get('name');

// Session flash

Session()->getFlashBag()->set('name', 'Test');
var_dump(Session()->getFlashBag()->has('name'));
var_dump(Session()->getFlashBag()->get('name'));

Upload file;

Handle upload.

	public function upload(Request $request){
		$request->files->get('parametersName')->move( FOLDER_UPLOAD, 'filename.png');

	}

Redirect;

Handle redirect url.

redirect( url('exemple/id/1') );

__ ;

Use pagination

use Atl\Pagination\Pagination;

$ofset                = 10; // Result query row number.
$config['pageStart']  = $page; // Number of page.
$config['ofset']      = $ofset; 
$config['totalRow']  = 50; // Number of count total row.
$config['baseUrl']   = url('/page/'); // Url base of pagination.

$pagination          = new Pagination($config);

echo $pagination->link( $config );

Use Model

Use model static

DB()->insert("account", [
	"user_name" => "foo",
	"email"     => "[email protected]"
]);

DB()->update("account", [
	"user_name" => "foo",
	"email"     => "[email protected]"
],[
	"id" => 1
]);

DB()->select("account", [
	"user_name",
	"email"
], [
	"user_id[>]" => 100
]);

DB()->select("account", "user_name", [
	"email" => "[email protected]"
]);
// WHERE email = '[email protected]'
 
DB()->select("account", "user_name", [
	"user_id" => 200
]);
// WHERE user_id = 200
 
DB()->select("account", "user_name", [
	"user_id[>]" => 200
]);
// WHERE user_id > 200
 
DB()->select("account", "user_name", [
	"user_id[>=]" => 200
]);
// WHERE user_id >= 200
 
DB()->select("account", "user_name", [
	"user_id[!]" => 200
]);
// WHERE user_id != 200
 
DB()->select("account", "user_name", [
	"age[<>]" => [200, 500]
]);
// WHERE age BETWEEN 200 AND 500
 
DB()->select("account", "user_name", [
	"age[><]" => [200, 500]
]);
// WHERE age NOT BETWEEN 200 AND 500
 
// [><] and [<>] is also available for datetime
DB()->select("account", "user_name", [
	"birthday[><]" => [date("Y-m-d", mktime(0, 0, 0, 1, 1, 2015)), date("Y-m-d")]
]);
//WHERE "create_date" BETWEEN '2015-01-01' AND '2015-05-01' (now)
 
// You can use not only single string or number value, but also array
DB()->select("account", "user_name", [
	"OR" => [
		"user_id" => [2, 123, 234, 54],
		"email" => ["[email protected]", "[email protected]", "[email protected]"]
	]
]);
// WHERE
// user_id IN (2,123,234,54) OR
// email IN ('[email protected]','[email protected]','[email protected]')
 
// [Negative condition]
DB()->select("account", "user_name", [
	"AND" => [
		"user_name[!]" => "foo",
		"user_id[!]" => 1024,
		"email[!]" => ["[email protected]", "[email protected]", "[email protected]"],
		"city[!]" => null,
		"promoted[!]" => true
	]
]);
// WHERE
// `user_name` != 'foo' AND
// `user_id` != 1024 AND
// `email` NOT IN ('[email protected]','[email protected]','[email protected]') AND
// `city` IS NOT NULL
// `promoted` != 1
 
// Or fetched from select() or get() function
DB()->select("account", "user_name", [
	"user_id" => DB()->select("post", "user_id", ["comments[>]" => 40])
]);
// WHERE user_id IN (2, 51, 321, 3431)

sheets's People

Contributors

leeit1992 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.