本文整理汇总了PHP中orm::facrtory方法的典型用法代码示例。如果您正苦于以下问题:PHP orm::facrtory方法的具体用法?PHP orm::facrtory怎么用?PHP orm::facrtory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orm
的用法示例。
在下文中一共展示了orm::facrtory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* used to create a location, requires the hidden fields for the latatude and longatude.
*/
public function create()
{
if ($this->access->allowed('locations', 'create')) {
$input = Validation::factory($this->input->post())->pre_filter('trim')->add_rules('name', 'required')->add_rules('status', 'required')->add_rules('group', 'required')->add_rules('latitude', 'required')->add_rules('longitude', 'required')->add_rules('address', 'required');
if ($input->validate()) {
$location = orm::Factory('location');
$location->name = $this->input->post('name');
$location->description = $this->input->post('description');
$location->url = $this->input->post('url');
$location->status = $this->input->post('status');
$location->group = $this->input->post('group');
$location->order = orm::facrtory('location')->where('group', $this->input->post('group'))->count_all();
$location->latitude = $this->input->post('latitude');
$location->longitude = $this->input->post('longitude');
$location->address = $this->input->post('address');
$images = $this->input->post('images');
$location->image = !is_null($images['logo']) ? $images['logo'] : 'logo.jpg';
if ($location->save()) {
$this->notification->add($this->i18n['system.location.success'], $location->name);
$cms = DOCROOT . 'application/' . SITE . '/media/cms/locations/' . $location->id;
// this will create the folder
if (file::tree($cms)) {
$file = $location->image;
// if there was no image set, then use the default
if (isset($images)) {
$path = DOCROOT . 'upload/' . $location->image;
// use the uploaded file
} else {
$path = 'application/' . SITE . '/media/cms/locations/logo.jpg';
}
if (file_exists($path)) {
if (copy($path, $cms . '/' . $file)) {
$this->notification->add($this->i18n['cms.image.success']);
} else {
$this->notification->add($this->i18n['cms.image.error']);
}
} else {
$this->notification->add($this->i18n['cms.image.error']);
}
} else {
$this->notification->add($this->i18n['cms.folder.error']);
}
url::redirect(url::area() . 'edit/' . $location->id);
} else {
$this->notification->add($this->i18n['system.location.error']);
}
} else {
foreach ($input->errors() as $key => $value) {
$this->notification->add($this->i18n['filter.' . $key . '.' . $value]);
}
}
}
url::redirect(url::area() . 'add/');
// name might not exist
}