本文整理汇总了PHP中app\models\Item::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::create方法的具体用法?PHP Item::create怎么用?PHP Item::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Item
的用法示例。
在下文中一共展示了Item::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param ProductRequest $request
* @return \Illuminate\Http\Response
*/
public function store(ProductRequest $request)
{
$input = $request->all();
$input['type'] = 'Product';
Item::create($input);
return redirect()->route('product.index')->withMessage('Product Added')->withStatus('success');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(CreateTaskRequest $request)
{
//
$item = \App\Models\Item::create($request->all());
$item->save();
return redirect('toDo');
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param ServiceRequest $request
* @return \Illuminate\Http\Response
*/
public function store(ServiceRequest $request)
{
$input = $request->all();
$input['type'] = 'Service';
Item::create($input);
return redirect()->back()->withMessage('Service Added')->withStatus('success');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validation_rules($request);
$item = $request->input();
Item::create($item);
Session::flash('flash_message', 'Data item layanan berhasil ditambahkan!');
return redirect('admin/item');
}
示例5: handle
/**
* Handle the command.
*
* @param CreateItemCommand $command
* @return boolean
*/
public function handle(CreateItemCommand $command)
{
$item = Item::create(['category_id' => $command->category_id, 'title' => $command->title, 'description' => $command->description, 'extra_description' => $command->extra_description, 'amount' => $command->amount, 'switch' => (int) $command->switch]);
if (!empty($item)) {
return $item;
}
return false;
}
示例6: run
public function run()
{
$i = 0;
do {
Item::create(['name' => $i . '-item', 'completed' => false]);
$i++;
} while ($i <= 10);
}
示例7: store
public function store(Request $request, $banqueId)
{
// verify request inputs
if (!$request->has(['label', 'valeur', 'id_Competence', 'id_TitreGItem']) || is_null($banqueId)) {
return response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST);
} else {
$item = Item::create(['label' => $request->input('label'), 'valeur' => $request->input('valeur'), 'id_Competence' => $request->input('id_Competence'), 'id_TitreGItem' => $request->input('id_TitreGItem'), 'id_Banque' => $banqueId]);
return is_null($item) ? response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST) : $item;
}
}
示例8: store
public function store(Request $request)
{
Log::info($request);
// verify request inputs
if (!$request->has(['label', 'situation_Clinique', 'instruction_Etudiant', 'instruction_MedObservateur', 'scenarios_Patient', 'id_Domaine', 'id_Critere', 'id_Systeme', 'id_Contexte', 'id_Plainte', 'diagnostic'])) {
return response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST);
} else {
$mBanque = json_decode($request->getContent(), true);
$banque = Banque::create(['label' => $mBanque['label'], 'situation_Clinique' => $mBanque['situation_Clinique'], 'instruction_Etudiant' => $mBanque['instruction_Etudiant'], 'instruction_MedObservateur' => $mBanque['instruction_MedObservateur'], 'scenarios_Patient' => $mBanque['scenarios_Patient'], 'id_Domaine' => $mBanque['id_Domaine'], 'id_Critere' => $mBanque['id_Critere'], 'id_Systeme' => $mBanque['id_Systeme'], 'id_Contexte' => $mBanque['id_Contexte'], 'id_Plainte' => $mBanque['id_Plainte'], 'diagnostic' => $mBanque['diagnostic']]);
foreach ($mBanque['titres'] as $mTitre) {
$titre = TitreGItem::create(['nom' => $mTitre['nom'], 'ponderation' => $mTitre['ponderation']]);
foreach ($mTitre['items'] as $mItem) {
$item = Item::create(['label' => $mItem['label'], 'valeur' => $mItem['valeur'], 'id_Competence' => $mItem['id_Competence'], 'id_TitreGItem' => $titre->id_TitreGItem, 'id_Banque' => $banque->id_Banque]);
}
}
foreach ($mBanque['auteurs'] as $auteur) {
Banque_Enseignant::create(['id_Enseignant' => $auteur, 'id_Banque' => $banque->id_Banque]);
}
return is_null($banque) ? response()->json(['error' => 'Bad request'], HttpResponse::HTTP_BAD_REQUEST) : $banque;
}
}
示例9: saveItem
/**
* Save item details
*
* @param array $data
* @return int
*/
public function saveItem($data)
{
unset($data['item_id']);
$item = Item::create($data);
return $item->id;
}