本文整理汇总了PHP中Line::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Line::save方法的具体用法?PHP Line::save怎么用?PHP Line::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Line
的用法示例。
在下文中一共展示了Line::save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$line1 = new Line();
$line1->clue = 'Carthage';
$line1->response = 'an ancient city on the northern coast of Africa, famous for fighting against Rome in Punic Wars; the sequel was better.';
$line1->sheet_id = 1;
$line1->save();
$line2 = new Line();
$line2->clue = 'Constantinople';
$line2->response = 'city established as new eastern capital of Roman Empire by emperor Constantine in AD 330; By coincidence Instanbul was once Constantinople.';
$line2->sheet_id = 1;
$line2->save();
$line3 = new Line();
$line3->clue = 'Pompeii';
$line3->response = 'ancient city in southwestern Italy that was buried by the eruption of Mount Vesuvius; Jon Snow would survive this disaster only to... well, you know the wall.';
$line3->sheet_id = 1;
$line3->save();
$line4 = new Line();
$line4->clue = 'Londinium';
$line4->response = 'Roman settlement founded in AD 43 on the site of what would be London, abandoned in 5th century; its Roman Legion would spark Arthurian legends.. maybe.';
$line4->sheet_id = 1;
$line4->save();
$line5 = new Line();
$line5->clue = 'Rome';
$line5->response = 'founded by Romulus and Remus, from Kingdom to Republic to Empire to birthplace of Italian cuisine.. hmmm.. pizza.';
$line5->sheet_id = 1;
$line5->save();
$line6 = new Line();
$line6->clue = 'papyrus';
$line6->response = 'a water-loving plant best known for being made into paper by the Egyptians; font used in Avatar.';
$line6->sheet_id = 2;
$line6->save();
$line7 = new Line();
$line7->clue = 'hieroglyphics';
$line7->response = 'system of writing made up of thousands of picture symbols created by the ancient Egyptians';
$line7->sheet_id = 2;
$line7->save();
$line8 = new Line();
$line8->clue = 'embalming';
$line8->response = 'process of preserving a person\'s (usually the pharaoh) body after death; involved pulling the brain out the nose; also used by mummy\'s to reconstitute themselves in modern day to excact their revenge.';
$line8->sheet_id = 2;
$line8->save();
$line9 = new Line();
$line9->clue = 'sarcophagus';
$line9->response = 'stone coffin for mummified bodies; not at all creepy.';
$line9->sheet_id = 2;
$line9->save();
$line10 = new Line();
$line10->clue = 'pyramid';
$line10->response = 'large structures built of brick or stone with four sides as burial sites or tombs for the pharaohs; there are between 113 and 138 identified pyramids; one was destroyed by the Transformers.';
$line10->sheet_id = 2;
$line10->save();
$line11 = new Line();
$line11->clue = 'Michigan';
$line11->response = 'American Robin';
$line11->sheet_id = 3;
$line11->save();
$line12 = new Line();
$line12->clue = 'Pennsylvania';
$line12->response = 'Ruffed Grouse';
$line12->sheet_id = 3;
$line12->save();
$line13 = new Line();
$line13->clue = 'Hawaii';
$line13->response = 'Hawaiian Goose';
$line13->sheet_id = 3;
$line13->save();
$line14 = new Line();
$line14->clue = 'Utah';
$line14->response = 'California Gull';
$line14->sheet_id = 3;
$line14->save();
$line15 = new Line();
$line15->clue = 'Arizona';
$line15->response = 'Cactus Wren';
$line15->sheet_id = 3;
$line15->save();
$line16 = new Line();
$line16->clue = 'Hungary';
$line16->response = 'Budapest';
$line16->sheet_id = 4;
$line16->save();
$line17 = new Line();
$line17->clue = 'Germany';
$line17->response = 'Berlin';
$line17->sheet_id = 4;
$line17->save();
$line18 = new Line();
$line18->clue = 'Iceland';
$line18->response = 'Reykjavík';
$line18->sheet_id = 4;
$line18->save();
$line19 = new Line();
$line19->clue = 'Liechtenstein';
$line19->response = 'Vaduz';
$line19->sheet_id = 4;
$line19->save();
$line20 = new Line();
$line20->clue = 'Italy';
$line20->response = 'Rome';
//.........这里部分代码省略.........
示例2: postLineAdd
public function postLineAdd()
{
$validator = Validator::make(Input::all(), Line::$rules);
if ($validator->fails()) {
return Redirect::to('branch/line-add')->withErrors($validator)->withInput();
}
$line = new Line();
$line->name = Input::get('name');
$line->code = Input::get('code');
$line->save();
return Redirect::to('branch/line')->with('success', '线路添加成功!');
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$validator = Validator::make(Input::all(), Sheet::$rules);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);
} else {
$sheet = Sheet::find($id);
$sheet->title = Input::get('title');
$sheet->public_or_private = Input::get('public_or_private');
$sheet->user_id = Auth::user()->id;
$result1 = $sheet->save();
$cluesArray = Input::get('cluesArray');
$responsesArray = Input::get('responsesArray');
$linesArray = Line::where('sheet_id', '=', $id)->lists('id');
foreach ($cluesArray as $key => $value) {
if (array_key_exists($key, $linesArray)) {
$line = Line::find($linesArray[$key]);
} else {
$line = new Line();
}
$line->sheet_id = $sheet->id;
$line->clue = $cluesArray[$key];
$line->response = $responsesArray[$key];
$result2 = $line->save();
}
if ($result1 && $result2) {
Session::flash('successMessage', 'This sheet was saved.');
// Log::info('This is some useful information.', Input::all());
return Redirect::route('sheets.index');
} else {
Session::flash('errorMessage', 'This sheet was not submitted.');
return Redirect::back()->withInput();
}
}
}