1. Go to this page and download the library: Download hashyoo/fast-laravel-orm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hashyoo / fast-laravel-orm example snippets
namespace Common\Model;
use HashyooFast\LaravelModel;
class Base extends LaravelModel
{
}
/**
* common model file Created by PhpStorm.
* Date: 2020/07/07
*/
namespace Common\Model;
class Users extends Base
{
protected $table = 'users';
protected $guarded = [];
}
namespace App\Http\Controllers;
use Common\Model\Users;
class IndexController
{
public function test(){
//格式参考LaravelModel里的demo方法
$arr_option = [];
//获取所有数据
User::laravelAll($arr_option);
User::laravelOption($arr_option)->get();
//指定条件数据sort字段自增5
User::laravelWhereOption($arr_option)->increment('sort', 5);
}
}
namespace Common\Repository;
use HashyooFast\LaravelRepository;
class BaseRepository extends LaravelRepository
{
}
namespace Common\Repository;
use Common\Model\Users;
class UsersRepository extends BaseRepository
{
/* 该方法必须定义 */
public function baseModel()
{
return new Users();
}
}
namespace App\Http\Controllers;
use Common\Repository\UsersRepository;
class IndexController
{
public function test(){
//格式参考LaravelModel里的demo方法
$arr_option = [];
//获取数据
UsersRepository::find(19,$arr_option);
UsersRepository::get_list($arr_option);
}
}