saifalbd/model-collection
Composer 安装命令:
composer require saifalbd/model-collection
包简介
convert php array to object like Laravel Model
README 文档
README
if you can want convert array to object or Multidimensional Arrays To Collection like laravel Eloquent Collection Then this Package Need for you . you can also call object like Associative Arrays object->key or object['key']
Getting Started
use Saifalbd\CustomModel\Model;
Model Create
on non-static method
$model = new Model();
$data = $model->add(array("name"=>"John", "email"=>"john@gmail.com", "age"=>33));
return object you can access $data["name"] or $data->name #####you can also add multiple
$collection = $model->add()->add()->add()->get()
return object collection you can access $collection[index]->property;
on static method
$data = Model::make(array("name"=>"John", "email"=>"john@gmail.com", "age"=>33));
return object you can access $data["name"] or $data->name
Collection Create
on non-static method
$model = new Model();
$collection = $model->addAll(
array("name"=>"Ram", "email"=>"ram@gmail.com", "age"=>23),
array("name"=>"Shyam", "email"=>"shyam23@gmail.com", "age"=>28),
array("name"=>"John", "email"=>"john@gmail.com", "age"=>33),
array("name"=>"Bob", "email"=>"bob32@gmail.com", "age"=>41)
);
return object collection you can access $collection[index]->property;
on static method
$collection = Model::makeAll(
array("name"=>"Ram", "email"=>"ram@gmail.com", "age"=>23),
array("name"=>"Shyam", "email"=>"shyam23@gmail.com", "age"=>28),
array("name"=>"John", "email"=>"john@gmail.com", "age"=>33),
array("name"=>"Bob", "email"=>"bob32@gmail.com", "age"=>41)
);
return object collection you can access $collection[index]->property;
note: if you can use this package for laravel project then call $collection->collection(); return Illuminate\Support\Collection
model set
$model = new Model();
$model->country = 'bangladesh'
model get
$model->country;
or
$model['country'];
collection in json
$model = new Model();
$json = $model->addAll(MultidimensionalArray)->toJson();
or
$json = Model::makeAll(MultidimensionalArray)->toJson();
INSTALL
composer require saifalbd/model-collection
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Mit
- 更新时间: 2019-07-21