本文整理汇总了PHP中app\Item::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::create方法的具体用法?PHP Item::create怎么用?PHP Item::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Item
的用法示例。
在下文中一共展示了Item::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store(ItemRequest $request)
{
try {
$customers = Customer::all();
Item::create($request->all());
$item = Item::orderBy('created_at', 'desc')->first();
foreach ($customers as $customer) {
Price::create(['item_id' => $item->id, 'customer_id' => $customer->id, 'custom_price' => $item->price, 'sellable' => '1', 'is_custom' => '0']);
}
return redirect('item')->with('message', 'Data berhasil dibuat!');
} catch (\Illuminate\Database\QueryException $e) {
return redirect('item')->with('message', 'Data dengan nama tersebut sudah digunakan!');
} catch (\PDOException $e) {
return redirect('item')->with('message', 'Data dengan nama tersebut sudah digunakan!');
}
}
示例2: store
public function store(Request $request)
{
$publish = 0;
$index_page = 0;
$extension = "";
if ($request['publish'] == 'on') {
$publish = 1;
}
if ($request['index_page'] == 'on') {
$index_page = 1;
}
//obtenemos el campo file definido en el formulario
$flag = 1;
$orderBy = DB::table('cms_categories')->where('active', '=', $flag)->max('order_by') + 1;
$file = $request->file('file');
if ($file != "") {
$media = \App\Media::find($request->id_album);
$path = $media->path . uniqid() . '.' . $file->getClientOriginalExtension();
$extension = $file->getClientOriginalExtension();
//indicamos que queremos guardar un nuevo archivo en el disco local
Storage::disk('local')->put($path, File::get($file));
} else {
$path = "";
}
$flag = 1;
$orderBy = DB::table('med_pictures')->where('active', '=', $flag)->max('order_by') + 1;
\App\Item::create(['id_album' => $request['id_album'], 'title' => $request['title'], 'description' => $request['description'], 'uri' => $path, 'publish' => $publish, 'publish_date' => $request['publish_date'], 'path' => $path, 'mime_type' => $extension, 'extension' => $extension, 'hits' => '0', 'order_by' => $orderBy, 'active' => '1', 'register_by' => '1', 'modify_by' => '1']);
return redirect('/admin/item/' . $request->id_album);
}
示例3: handle
/**
* Update podcast items
*
* @return mixed
*/
public function handle()
{
$uniquePodcasts = DB::table('podcasts')->select('id', 'feed_url', 'machine_name')->groupBy('machine_name')->get();
foreach ($uniquePodcasts as $podcast) {
$usersSubscribedToThisPodcast = DB::table('podcasts')->select('user_id', 'id as podcast_id')->where('machine_name', '=', $podcast->machine_name)->get();
$items = Feeds::make($podcast->feed_url)->get_items();
// Calculate 48 hours ago
$yesterday = time() - 24 * 2 * 60 * 60;
foreach ($items as $item) {
$itemPubDate = $item->get_date();
if ($item->get_date('U') > $yesterday) {
// new items
foreach ($usersSubscribedToThisPodcast as $subscriber) {
$podcastItemsCount = DB::table('items')->select('user_id', 'title', 'podcast_id')->where('title', '=', strip_tags($item->get_title()))->where('user_id', '=', $subscriber->user_id)->where('podcast_id', '=', $subscriber->podcast_id)->count();
// if this item is not already in the DB
if ($podcastItemsCount == 0) {
Item::create(['user_id' => $subscriber->user_id, 'title' => strip_tags($item->get_title()), 'description' => strip_tags(str_limit($item->get_description(), 100)), 'published_at' => $item->get_date('Y-m-d'), 'url' => $item->get_permalink(), 'audio_url' => $item->get_enclosure()->get_link(), 'podcast_id' => $subscriber->podcast_id]);
}
}
} else {
break;
}
}
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
for ($i = 0; $i < 300; $i++) {
Item::create(['name' => $faker->shuffle($faker->name()), 'description' => $faker->text(), 'icon' => $faker->imageUrl(100, 100, 'abstract')]);
}
}
示例5: store
/**
*
* Store - Processes $_POSTs from the Add Item page
* Parameter - CreateItemRequest
*/
public function store(Requests\CreateItemRequest $request)
{
$input = $request->all();
$input['user_id'] = Auth::id();
Item::create($input);
return redirect('items');
}
示例6: run
public function run()
{
DB::table('items')->delete();
Item::create(['name' => 'Truc', 'description' => 'non applicable', 'price' => '99.99', 'stock' => 5, 'img_url' => '/images/filler.jpg', 'category_id' => 1]);
Item::create(['name' => 'Machin', 'description' => 'non applicable', 'price' => '23.99', 'stock' => 3, 'img_url' => '/images/filler.jpg', 'category_id' => 2]);
Item::create(['name' => 'Bidule', 'description' => 'non applicable', 'price' => '123.99', 'stock' => 0, 'img_url' => '/images/filler.jpg', 'category_id' => 3]);
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('items')->delete();
for ($i = 1; $i <= 100; $i++) {
Item::create(array('title' => 'item test ' . $i));
}
}
示例8: store
public function store(ItemCreateRequest $request)
{
$item = Item::create($request->postFillData());
$itemid = $item->id;
$employeeid = Auth::user()->id;
$logs = ActivityLog::create(['employee_id' => $employeeid, 'activity' => 'Add Item', 'table_affected' => 'item', 'primary_key' => $itemid, 'column_affected' => 'all']);
return redirect()->route('erp_system.item.index')->withSuccess('New Item Successfully Created.');
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, ['category_id' => 'required', 'name' => 'required', 'description' => 'required', 'cost' => 'required']);
$extension = $request->file('image')->getClientOriginalExtension();
$item = Item::create(['category_id' => $request->input('category_id'), 'name' => $request->input('name'), 'description' => $request->input('description'), 'cost' => $request->input('cost'), 'image_type' => $extension]);
$storage = Storage::disk('s3')->put('/items/' . $item->id . '.' . $extension, file_get_contents($request->file('image')->getRealPath()), 'public');
return redirect('items')->with('flash_message', 'New Item added: ' . $item->name);
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(ItemRequest $request, $course_url, $stage_url)
{
$name = $request->name;
$url = UrlSanitizer::sanitize($name);
$request["url"] = $url;
$item = Item::create($request->all());
return redirect()->route('items.index', ['course_url' => $course_url, 'stage_url' => $stage_url]);
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$category_ids = explode(',', $request->input('category_ids'));
$item = App\Item::create($request->all());
foreach ($category_ids as $category_id) {
$item->categories()->attach($category_id);
}
flash()->success("Success!", "New item <strong>" . e($item->name) . "</strong> has been created.");
return redirect()->action('ItemsController@index');
}
示例12: newItem
protected static function newItem($id, $name, $headers, $entries)
{
$item = Item::create(['section_id' => $id, 'name' => $name]);
foreach ($headers as $header => $value) {
ItemHeader::create(['item_id' => $item->id, 'name' => $header, 'value' => $value]);
}
foreach ($entries as $key => $entry) {
Entry::create(['item_id' => $item->id, 'entry' => $entry, 'ordered' => $key]);
}
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Item::create(['articulo_id' => 1, 'romano' => 'I', 'descripcion' => 'Cumplir con las normas de trabajo aplicables.']);
Item::create(['articulo_id' => 1, 'romano' => 'II', 'descripcion' => 'Expedir y dar a conocer entre los trabajadores las normas que permitan el cumplimiento de las condiciones, políticas, criterios y procedimientos en general encaminados a mantener el orden, la disciplina y el buen funcionamiento del centro de trabajo.']);
Item::create(['articulo_id' => 1, 'romano' => 'III', 'descripcion' => 'Expedir a favor del trabajador que tenga derecho, el nombramiento de acuerdo a la categoría que desempeñe.']);
Item::create(['articulo_id' => 1, 'romano' => 'IV', 'descripcion' => 'Cubrir el salario de los trabajadores y las demás prestaciones y beneficios a que tenga derecho el trabajador.']);
Item::create(['articulo_id' => 2, 'romano' => 'I', 'descripcion' => 'Cumplir con las normas de trabajo que les sean aplicables.']);
Item::create(['articulo_id' => 2, 'romano' => 'II', 'descripcion' => 'Cumplir con todas las normas de orden técnico y administrativo que dicte la Institución a través de manuales, reglamentos, circulares o reglas de carácter general o especial.']);
Item::create(['articulo_id' => 2, 'romano' => 'III', 'descripcion' => 'Acatar las órdenes e instrucciones que reciban de superiores, en atención al servicio que prestan.']);
Item::create(['articulo_id' => 2, 'romano' => 'IV', 'descripcion' => 'Observar las medidas preventivas de seguridad e higiene que contemplen las normas a que están sujetos, así como las que indiquen las autoridades competentes y la institución en beneficio de los trabajadores y del centro de trabajo.']);
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
//$input = Request::all();
$request->merge(['user' => Auth::id()]);
$this->validate($request, ['item_name' => 'required', 'sku' => 'required|numeric|unique:items,sku', 'price' => 'required', 'quantity' => 'required|numeric', 'user' => 'required']);
Item::create($request->all());
//delete scanner
$email = User::where('id', Auth::id())->first()->email;
$scan = Scan::where('userEmail', $email)->delete();
return redirect('inventory');
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(ItemRequest $request)
{
//
$input = $request->all();
$item = Item::create($input);
$warehouse = Warehouse::first();
if ($warehouse != null) {
$data = ['item_id' => $item->id, 'warehouse_id' => $warehouse->id, 'qtyonhand' => 0.0];
Itemsite::create($data);
}
return redirect('items');
}