当前位置: 首页>>代码示例>>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;未经允许,请勿转载。