本文整理汇总了PHP中Streams::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Streams::save方法的具体用法?PHP Streams::save怎么用?PHP Streams::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Streams
的用法示例。
在下文中一共展示了Streams::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postAddStreams
public function postAddStreams()
{
$validator = Validator::make(Input::all(), array('stream_name' => 'required|max:30|min:3'));
if ($validator->fails()) {
$response = array('status' => 'failed', 'msg' => 'Item is not updated', 'errors' => $validator, 'error_messages' => $validator->messages());
return Response::json($response);
} else {
$new_stream = Input::get('stream_name');
$new_stream_id = Input::get('stream_id');
if ($new_stream_id) {
$streams = Streams::find($new_stream_id);
$streams->stream_name = ucwords($new_stream);
if ($streams->save()) {
$response = array('status' => 'success', 'data_send' => array('id' => $streams->id, 'inserted_item' => $streams->stream_name));
return Response::json($response);
}
} else {
$streams = new Streams();
$streams->stream_name = ucfirst($new_stream);
$streams->school_id = $this->getSchoolId();
if ($streams->save()) {
$response = array('status' => 'success', 'data_send' => array('id' => $streams->id, 'inserted_item' => $streams->stream_name));
return Response::json($response);
}
}
}
$response = array('status' => 'failed', 'msg' => 'Item is not updated');
return Response::json($response);
}