本文整理匯總了PHP中app\models\Event::lookup方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::lookup方法的具體用法?PHP Event::lookup怎麽用?PHP Event::lookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Event
的用法示例。
在下文中一共展示了Event::lookup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postNew
/**
* new-Action (Formularauswertung)
*/
public function postNew()
{
$validator = Validator::make(Request::all(), Event::$rules);
// validation has passed, write events in range on that date to xml File
$geocoding_arr = Event::lookup(Request::input('adress'));
$date = strtotime(Request::input('date'));
(double) ($lat = $geocoding_arr['latitude']);
(double) ($lng = $geocoding_arr['longitude']);
//Start XML file, create parent node
$xml = new XMLWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');
if ($validator->passes()) {
// validation has passed, save event in DB
$event = new Event();
$event->title = Request::input('name');
$event->content = Request::input('content');
$event->link = Request::input('link');
$event->type = Request::input('type');
$event->latitude = $lat;
$event->longitude = $lng;
$event->save();
return redirect('events')->with('message', 'success|Event erfolgreich angelegt!');
} else {
// validation has failed, display error messages
return redirect('events/new')->with('message', 'danger|Die folgenden Fehler sind aufgetreten:')->withErrors($validator)->withInput();
}
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$geocoding_arr = Event::lookup(Request::input('adress'));
$date = strtotime(Request::input('date'));
(double) ($lat = $geocoding_arr['latitude']);
(double) ($lng = $geocoding_arr['longitude']);
//
$event = new Event();
$event->title = Request::input('title');
$event->content = Request::input('content');
$event->link = Request::input('link');
$event->type = Request::input('type');
$event->latitude = $lat;
$event->longitude = $lng;
$event->save();
$response = new \stdClass();
$response->success = true;
$response->total = 1;
$response->data = $event;
return response()->json($response);
}