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


PHP Event::create方法代碼示例

本文整理匯總了PHP中app\models\Event::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::create方法的具體用法?PHP Event::create怎麽用?PHP Event::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Event的用法示例。


在下文中一共展示了Event::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('events')->delete();
     for ($i = 1; $i <= 100; $i++) {
         Event::create(['title' => '我是活動 - ' . $i, 'content' => 'content ' . $i, 'begin_time' => \Carbon\Carbon::now(), 'end_time' => \Carbon\Carbon::now(), 'user_count' => rand(0, 1000), 'user_id' => 1]);
     }
 }
開發者ID:qloog,項目名稱:laravel5-backend,代碼行數:12,代碼來源:EventsTableSeeder.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('events')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 50; $i++) {
         Event::create(['title' => $faker->sentence(6), 'slug' => $faker->slug(), 'time' => $faker->randomElement(['5-7', '7-9', '6-8']), 'address' => $faker->address, 'latitude' => $faker->latitude, 'longitude' => $faker->longitude, 'description' => $faker->paragraph(4), 'website' => $faker->url, 'facebook' => $faker->url, 'user_id' => $faker->randomElement(range(1, 30))]);
     }
 }
開發者ID:byhbt,項目名稱:laravel-skeleton,代碼行數:13,代碼來源:EventTableSeeder.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //dd(Input::get('data'));
     $data = Input::get('data');
     foreach ($data as $key => $value) {
         if (Event::find($value['id']) != null) {
             Event::find($value['id'])->update(['title' => $value['title'], 'start' => $value['start'], 'end' => $value['end']]);
         } else {
             Event::create(array('title' => $value['title'], 'start' => $value['start'], 'end' => $value['end']));
         }
     }
 }
開發者ID:phanngoc,項目名稱:internal-tool,代碼行數:17,代碼來源:EventController.php

示例4: create

 public function create(EventRequest $request)
 {
     $this->authorize('create-event');
     $input = $request->all();
     $event = Event::create($input);
     // Save event image if a file was uploaded
     if ($request->hasFile('image')) {
         $event->image = $this->handleUpload($request);
     }
     $event->save();
     $request->session()->flash('success', 'Your event has been created.');
     return redirect('/event/' . $event->id);
 }
開發者ID:Zaskoda,項目名稱:laravel-voldb,代碼行數:13,代碼來源:EventController.php

示例5: create

 /**
  * Create a new event.
  *
  * @param array $data
  * @return Event
  * @throws Exception
  */
 public function create(array $data)
 {
     try {
         DB::beginTransaction();
         // Create venue
         $venue = EventVenue::create(['name' => $data['venue']['name'], 'lat' => $data['venue']['lat'], 'lng' => $data['venue']['lng'], 'address' => $data['venue']['address'], 'url' => $data['venue']['url']]);
         // Create event
         $event = Event::create(['user_id' => $data['event']['user_id'], 'type_id' => $data['event']['type_id'], 'status_id' => empty($data['event']['status_id']) ? EventStatus::ACTIVE : $data['event']['status_id'], 'venue_id' => $venue->id, 'title' => $data['event']['title'], 'start_at' => $data['event']['start_at'], 'description' => $data['event']['description']]);
         DB::commit();
         return $event;
     } catch (\Exception $e) {
         DB::rollBack();
         throw $e;
     }
 }
開發者ID:slicvic,項目名稱:wgg,代碼行數:22,代碼來源:EventRepository.php

示例6: store

 public function store(Requests\CreateEventRequest $request)
 {
     $params = $request->except(['_token']);
     $date = \DateTime::createFromFormat('m/d/Y', $params['date']);
     $params['date'] = $date->format('Y-m-d');
     $params['user_id'] = Auth::user()->id;
     $event = Event::create($params);
     if ($event) {
         $hasAttachment = $request->hasFile('files');
         if ($hasAttachment) {
             $images = $request->file('files');
             $this->handleAttachedImages($images, $event->id);
         }
         $request->session()->flash("notif", "Event successfully added");
         return redirect('/events');
     }
     return redirect()->back()->withInput($request->all());
 }
開發者ID:arjayads,項目名稱:all-star,代碼行數:18,代碼來源:EventsController.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \App\Models\Event::create(['name' => 'shimano gran fondo 2015', 'slug' => 'shimano-gran-fondo-2015', 'description' => 'a massive ride starting from SM City-Tarlac  and ending at the Monasterio de Tarlac -- a 73.8-kilometer  route for the Gran Fondo and 52.4-kilometer route for', 'location' => 'Monasterio de Tarlac, Philippines', 'start_datetime' => '2015-11-28', 'end_datetime' => '2015-11-28']);
 }
開發者ID:aindong,項目名稱:cmnterprise-front,代碼行數:9,代碼來源:EventsTableSeeder.php

示例8: create

 public function create(array $data)
 {
     return Event::create(['title' => $data['title'], 'place' => $data['place'], 'space_remained' => $data['space_remained'], 'excerpt' => $data['excerpt'], 'description' => $data['description'], 'user_id' => Auth::user()->id]);
 }
開發者ID:Asekahud,項目名稱:Web_Programming,代碼行數:4,代碼來源:EventController.php

示例9: cloneEvent

 public function cloneEvent(Request $request, Event $event)
 {
     $this->authorize('create-event');
     $this->validate($request, ['start_date' => 'required|date_format:Y-m-d']);
     // Set up event information
     $startDate = new Carbon($event->start_date);
     $endDate = new Carbon($event->end_date);
     $newStartDate = new Carbon($request->input('start_date'));
     $departments = $event->departments;
     // Find the difference of the start dates
     $difference = $startDate->diffInSeconds($newStartDate);
     // Create new event from old event data
     $newEvent = Event::create(['name' => $event->name, 'description' => $event->description, 'start_date' => $startDate->addSeconds($difference)->format('Y-m-d'), 'end_date' => $endDate->addSeconds($difference)->format('Y-m-d')]);
     // Add the image manually because it's not automatically fillable
     if ($event->image) {
         $newEvent->image = $event->image;
         $newEvent->save();
     }
     // Loop through event departments
     foreach ($departments as $department) {
         // Create new department
         $newDepartment = new Department();
         $newDepartment->event_id = $newEvent->id;
         $newDepartment->save();
         // Because the event_id isn't fillable, we have to define it first and then update
         $newDepartment->update(['name' => $department->name, 'description' => $department->description, 'roles' => $department->roles]);
         // Loop through shifts
         $shifts = $department->shifts;
         foreach ($shifts as $shift) {
             // Adjust shift dates
             $shift->start_date = new Carbon($shift->start_date);
             $shift->end_date = new Carbon($shift->end_date);
             $shift->start_date = $shift->start_date->addSeconds($difference)->format('Y-m-d');
             $shift->end_date = $shift->end_date->addSeconds($difference)->format('Y-m-d');
             // Update the department ID
             $shift->department_id = $newDepartment->id;
             $newShift = Shift::create(['department_id' => $newDepartment->id, 'name' => $shift->name, 'start_date' => $shift->start_date, 'end_date' => $shift->end_date, 'start_time' => $shift->start_time, 'end_time' => $shift->end_time, 'duration' => $shift->duration, 'roles' => $shift->roles]);
             Slot::generate($newShift);
         }
     }
     $request->session()->flash('success', 'Event has been cloned.');
     return redirect('/event/' . $newEvent->id);
 }
開發者ID:playatech,項目名稱:laravel-voldb,代碼行數:43,代碼來源:EventController.php

示例10: create

 /**
  * создаем событие от турникета, и вызываем События для рассылки пуш
  * @param $attributes
  * @return static
  */
 public function create($attributes)
 {
     $event = Event::create($attributes);
     event(new ChildEventWasCreated($event));
     return $event;
 }
開發者ID:sasik-github,項目名稱:system.pro,代碼行數:11,代碼來源:EventRepository.php

示例11: run

 public function run()
 {
     Event::create(['name' => 'name', 'description' => '...', 'user_id' => 1, 'school_id' => 1]);
 }
開發者ID:Retsediv,項目名稱:edu,代碼行數:4,代碼來源:EventTableSeeder.php

示例12: createEventsForCard

 private function createEventsForCard($cardNumber)
 {
     \App\Models\Event::create(['card_number' => $cardNumber, 'event_type_id' => \App\Models\Event::TYPE_ENTER]);
     \App\Models\Event::create(['card_number' => $cardNumber, 'event_type_id' => \App\Models\Event::TYPE_EXIT]);
 }
開發者ID:sasik-github,項目名稱:system.pro,代碼行數:5,代碼來源:CreateUserParentChildrenSeeder.php

示例13: 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, ['description' => 'required', 'datetime' => 'required']);
     Event::create(['description' => $request->get('description'), 'datetime' => Carbon::parse($request->get('datetime'))]);
     return redirect('admin/events');
 }
開發者ID:scotthummel,項目名稱:lambdaphx,代碼行數:12,代碼來源:EventController.php

示例14: createEvents

function createEvents($events)
{
    foreach ($events as $event) {
        Event::create($event);
    }
}
開發者ID:bsampaio,項目名稱:Criobanco,代碼行數:6,代碼來源:start.php

示例15: run

 public function run()
 {
     DB::table('events')->delete();
     Event::create(['title' => '175th Anniversary Lecture Series', 'place' => 'Quayside', 'excerpt' => 'AS part of the University of Huddersfield’s 175th anniversary celebrations.', 'description' => 'AS part of the University of Huddersfield’s 175th anniversary celebrations, members of the public can attend free lectures delving into the origins of adult education in the town.  It is a story that has cast of characters including Charles Dickens and the Brontës, plus pioneer science .', 'user_id' => '1', 'space_remained' => 0]);
     Event::create(['title' => 'Table Tennis', 'place' => 'University Sports Hall', 'excerpt' => 'THIS FRIDAY come and see Matt Stanforth, England Table Tennis Coach,', 'description' => 'THIS FRIDAY come and see Matt Stanforth, England Table Tennis Coach, for workshops and tips and to play casual games. Dont forget to come to Student Central from 2.00pm, the table tennis tables will be set up for casual games and we re also selling hotdogs!', 'user_id' => '1', 'space_remained' => 25]);
     Event::create(['title' => 'Bengali New Year', 'place' => 'Student Central', 'excerpt' => 'Join the bengali new year today in Student Central', 'description' => 'Join the bengali new year today in Student Central', 'user_id' => '2', 'space_remained' => 30]);
     Event::create(['title' => 'Holi Celebrations', 'place' => 'Hindu Temple', 'excerpt' => 'Join tomorrow Holi celebrations at the Huddersfield Hindu Temple,..', 'description' => 'ight before Holi with a Holika bonfire where people gather, sing, dance and party.', 'user_id' => '2', 'space_remained' => 15]);
     Event::create(['title' => 'Pakistan Resolution Day', 'place' => 'Quayside', 'excerpt' => 'Happy Pakistan Resolution Day to our Pakistani student society and students..', 'description' => 'Happy Pakistan Resolution Day to our Pakistani student society and students. Dont miss the event tonight at 6pm in Quayside hosted by Huddersfield University Pakistan Society!', 'user_id' => '3', 'space_remained' => 12]);
 }
開發者ID:Asekahud,項目名稱:Web_Programming,代碼行數:9,代碼來源:DatabaseSeeder.php


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