本文整理汇总了PHP中Area::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Area::where方法的具体用法?PHP Area::where怎么用?PHP Area::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Area
的用法示例。
在下文中一共展示了Area::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* Interviews are submitted as sets of tags and responses to questionnaires.
*
* @return Response
*/
public function store()
{
$v = Validator::make(Request::all(), ['type' => 'required|string', 'questionSet' => 'required|string', 'recordedAt' => 'required', 'questions' => 'array', 'taggable' => 'array', 'location' => 'required|string', 'area' => 'required|string', 'houseno' => 'string']);
if ($v->fails()) {
return Response::json(['errors' => $v->errors()], 400);
}
$Date = Carbon::createFromTimeStamp(Input::get('recordedAt'));
$interview = Interview::firstOrNew(['date' => $Date, 'interviewer_id' => Auth::user()->id]);
$Questionnaire = Questionnaire::where('name', '=', Input::get('questionSet'))->first();
// important to fail here, you shouldn't be able to submit an interview for a questionnaire that doesn't exist
if (!$Questionnaire) {
return Response::json(['message' => 'questionnaire "' . Input::get('questionSet') . '" does not exist'], 400);
}
$interview->questionnaire_id = $Questionnaire->id;
$interview->type = Input::get('type');
// similarly, area has to exist already
$area = Area::where(['name' => Input::get('area')])->first();
if (!$area) {
return Response::json(['message' => 'area "' . Input::get('area') . '" does not exist'], 400);
}
// although we can allow for dynamically adding new locations as they come in.
$location = Location::firstOrCreate(['name' => Input::get('location'), 'area_id' => $area->id]);
$interview->location_id = $location->id;
if (Input::has('houseno')) {
$interview->house_number = Input::get('houseno');
}
$interview->save();
if (Input::has('questions') && $interview->type === 'interview') {
foreach (Input::get('questions') as $response) {
InterviewResponse::create(['question' => $response['question'], 'answer' => $response['answer'], 'interview_id' => $interview->id]);
}
}
if (Input::has('taggable') && $interview->type === 'interview') {
foreach (Input::get('taggable') as $list) {
if (isset($list['id'])) {
$this->saveTagsToQuestionnaire($list);
}
$TagList = new TagList();
$TagList->name = $list['name'];
$interview->tagLists()->save($TagList);
foreach ($list['tagged'] as $tag) {
$TagList->tags()->save(Tag::create(['name' => $tag, 'tag_list_id' => $TagList->id]));
}
}
}
$interview->push();
return Response::json(Interview::with('responses')->find($interview->id), 200);
}
示例2: store
/**
* Store a newly created resource in storage.
* POST /area
*
* @return Response
*/
public function store()
{
$V = Validator::make(Input::all(), ['name' => 'required|string']);
if ($V->fails()) {
return Response::json($V->messages()->all(), 400);
}
$name = Input::get('name');
$Area = Area::where('name', '=', $name);
if ($Area->count() > 0) {
// already exists :/
return Response::json($Area->toArray(), 409);
}
$NewArea = new Area();
$NewArea->name = $name;
$NewArea->save();
return Response::json($NewArea->toArray(), 201);
}
示例3: search
public function search(Request $request)
{
$profesionales = Area::where('nombre_profesional', 'like', '%' . $request->nombre . '%')->get();
return \View::make('Profesional/list_profesional', compact('profesionales'));
}
示例4: eliminarItem
public function eliminarItem()
{
if (Auth::User()->Rol_Id == 7 or Auth::User()->Rol_Id == 1) {
$IdContenido = Request::get('IdContenido');
$areaActual = Request::get('IdArea');
$IdSeccion = Request::get('IdSeccion');
$IdATS = Request::get('IdATS');
$IdTipoContenido = Request::get('TipoContenido');
$Item = new Contenido();
$areaActualNombre = Area::where('IdArea', $areaActual)->first();
$Seccion = Secciones::where('IdSeccion', $IdSeccion)->first();
if ($Item->eliminarItem($IdContenido)) {
echo '<script type="text/javascript">alert("' . 'Se ha eliminado el Item' . '")</script>';
$TablaDeContenido = Contenido::join('area_tiene_secciones', 'ATS_Id', '=', 'area_tiene_secciones.IdATS')->where('area_tiene_secciones.Area_Id', '=', $areaActual)->where('area_tiene_secciones.Secciones_Id', '=', $IdSeccion)->get();
Session::flash('msg', 'Item eliminado correctamente.');
return View::make('SIG.editarContenido', array('areaActual' => $areaActual, 'areaActualNombre' => $areaActualNombre, 'Seccion' => $Seccion, 'IdATS' => $IdATS, 'Items' => $TablaDeContenido, 'TipoDeContenido' => $IdTipoContenido));
} else {
$TablaDeContenido = Contenido::join('area_tiene_secciones', 'ATS_Id', '=', 'area_tiene_secciones.IdATS')->where('area_tiene_secciones.Area_Id', '=', $areaActual)->where('area_tiene_secciones.Secciones_Id', '=', $IdSeccion)->get();
Session::flash('msgWarning', 'Error en la aplicación, vuelva a intentarlo');
return View::make('SIG.editarContenido', array('areaActual' => $areaActual, 'areaActualNombre' => $areaActualNombre, 'Seccion' => $Seccion, 'IdATS' => $IdATS, 'Items' => $TablaDeContenido, 'TipoDeContenido' => $IdTipoContenido));
}
} else {
return Redirect::to('/SIG');
}
}
示例5: getBySlug
/**
* Get area by slug
*
* @param string $slug
* @param int $publish
* @return \FIIP\Areas\Area|null
*/
public function getBySlug($slug, $publish = 1, $county)
{
return Area::where('slug', $slug)->where('publish', $publish)->where('county_id', $county)->first();
}
示例6: getAreaList
/**
* Get area list for rendering areas.
*
* @return void
*/
public function getAreaList($areaGroupId = NULL, $areas = array())
{
global $data;
global $settings;
$stmt = Area::where('city_id', '=', $data['area']['id']);
if ($areaGroupId != NULL) {
$stmt->where('area_group_id', '=', $areaGroupId);
}
if (!empty($areas)) {
$stmt->whereIn('code', $areas);
$stmt->groupBy('code');
}
$area = $stmt->get()->toArray();
return $area;
}