當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::create方法代碼示例

本文整理匯總了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!');
     }
 }
開發者ID:Herlanggaws,項目名稱:givani,代碼行數:16,代碼來源:ItemsController.php

示例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);
 }
開發者ID:gitsolution,項目名稱:blog,代碼行數:29,代碼來源:ItemController.php

示例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;
             }
         }
     }
 }
開發者ID:MehmetNuri,項目名稱:Podcastwala,代碼行數:30,代碼來源:UpdatePodcastItems.php

示例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')]);
     }
 }
開發者ID:benjides,項目名稱:terrabattlez,代碼行數:12,代碼來源:ItemSeeder.php

示例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');
 }
開發者ID:sgottenyc,項目名稱:laravel_login,代碼行數:12,代碼來源:ItemsController.php

示例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]);
 }
開發者ID:starmatt,項目名稱:webpapa,代碼行數:7,代碼來源:ItemsTableSeeder.php

示例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));
     }
 }
開發者ID:zc1415926,項目名稱:angular-laravel-pagination,代碼行數:12,代碼來源:ItemDataSeeder.php

示例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.');
 }
開發者ID:husseinsbm,項目名稱:erp-system-prototype,代碼行數:8,代碼來源:ItemController.php

示例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);
 }
開發者ID:robboyland,項目名稱:ecom,代碼行數:14,代碼來源:ItemsController.php

示例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]);
 }
開發者ID:Kenneth058,項目名稱:adminclubinnova,代碼行數:14,代碼來源:ItemController.php

示例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');
 }
開發者ID:nickcoad,項目名稱:happy-lister,代碼行數:16,代碼來源:ItemsController.php

示例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]);
     }
 }
開發者ID:joaopramos,項目名稱:online-cv-builder,代碼行數:10,代碼來源:UserSeeder.php

示例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.']);
 }
開發者ID:JCarlosR,項目名稱:SIL,代碼行數:16,代碼來源:ItemsTableSeeder.php

示例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');
 }
開發者ID:jasmine24,項目名稱:cashflow,代碼行數:16,代碼來源:InventoryController.php

示例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');
 }
開發者ID:seahouse,項目名稱:hxerp,代碼行數:17,代碼來源:ItemsController-bak.php


注:本文中的app\Item::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。