本文整理汇总了PHP中app\Event::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::create方法的具体用法?PHP Event::create怎么用?PHP Event::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Event
的用法示例。
在下文中一共展示了Event::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
for ($i = 1; $i < 40; $i++) {
Event::create(['title' => 'title', 'body' => 'event' . $i, 'time' => date("Y/m/d"), 'location' => 'zhejiang']);
}
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request, Studio $studio)
{
$event = Event::create($this->prepare($request, $studio));
$event->pieces()->sync($this->prepareTags($request));
$event->categories()->sync($this->prepareTags($request, 'category_list'));
return redirect()->action('Admin\\StudioEventsController@show', [$studio->id, $event->id]);
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
if (Auth::check()) {
# code...
if (Auth::user()->type == 1) {
# code...
$rules = ['activity_id' => 'required|integer', 'event_name' => 'required|unique:events', 'image_path' => 'required|image'];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
# code...
return redirect()->back()->withErrors($validator);
}
if ($request->hasFile('image_path')) {
$input = $request->all();
$image = $input['image_path'];
$name = '' . $input['event_name'] . '.png';
//dd($name);
$image = $image->move(public_path() . '/images/events/', studly_case($name));
$url = '/images/events/' . studly_case($name);
$event = Event::create(['activity_id' => $input['activity_id'], 'event_name' => $input['event_name'], 'image_path' => $url]);
if ($event) {
# code...
$subscribedUsers = $this->getUsers($event->activity_id);
$this->sendEmail($subscribedUsers, $event->event_name);
Session::flash('eventCreated', $event->event_name . ' has been created!');
} else {
return "error creating the event.";
}
return redirect('home');
}
return redirect('/');
}
}
return redirect('/');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$user = Auth::user();
$group = $user->group;
$event = Event::create(['group_id' => $group->id, 'date' => $request->date, 'male_name' => $request->male_name, 'female_name' => $request->female_name, 'guests_count' => $request->guests_count, 'place' => $request->place]);
return redirect(url('/'));
}
示例5: create
public function create(array $data)
{
$event_time = $this->dateToTime($data['event_time']);
$start_at = $event_time['start_time'];
$end_at = $event_time['end_time'];
return Event::create(['title' => $data['title'], 'planner' => $data['planner'], 'description' => $data['description'], 'start_at' => $start_at, 'end_at' => $end_at]);
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$faker = \Faker\Factory::create();
$user = User::create(['name' => 'Christian Kasperbauer', 'email' => 'chris.kasperbauer@gmail.com', 'password' => bcrypt('grütze'), 'phone' => '0176-23152819', 'misc' => 'Friedrich-Ebert-Ring 4
97072 Würzburg
(Ton-)Technik, KRIS, Website!', 'rights' => 'all']);
$user2 = User::create(['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt('grütze'), 'phone' => $faker->phoneNumber, 'misc' => $faker->sentence()]);
for ($i = 0; $i <= 15; $i++) {
User::create(['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt('grütze'), 'phone' => $faker->phoneNumber, 'misc' => $faker->sentence()]);
}
Category::insert([['name' => 'Konzert', 'class' => 'light-green'], ['name' => 'Partey', 'class' => 'funky'], ['name' => 'Theater', 'class' => 'red'], ['name' => 'Kino', 'class' => 'amber'], ['name' => 'Sonstiges', 'class' => 'blue-grey'], ['name' => 'Wort', 'class' => 'light-blue']]);
$user->events()->save(Event::create(['scheduled_at' => Carbon::now()->addDays(4), 'category_id' => rand(1, 6), 'title' => 'Basement Blast', 'subtitle' => 'Geballer im Keller', 'description' => $faker->paragraph(10), 'admission' => 'donation', 'genre' => 'Metal', 'google_event_id' => str_random(12)]));
$user2->events()->save(Event::create(['scheduled_at' => Carbon::now()->addDays(9), 'category_id' => rand(1, 6), 'title' => 'Boxbeutel Boombox', 'subtitle' => 'Lecker Weinchen', 'description' => $faker->paragraph(10), 'admission' => 'free', 'genre' => 'Suff', 'google_event_id' => str_random(12)]));
$user->events()->save(Event::create(['scheduled_at' => Carbon::now()->addDays(2)->addMonth(), 'category_id' => rand(1, 6), 'title' => 'Beats & Lyrics', 'subtitle' => 'Freestyle Chypher', 'description' => $faker->paragraph(10), 'admission' => 'donation', 'genre' => 'HipHop', 'google_event_id' => str_random(12)]));
$user2->events()->save(Event::create(['scheduled_at' => Carbon::now()->subDays(2), 'category_id' => rand(1, 6), 'title' => 'Schon vorbei', 'subtitle' => 'Schade, du warst du spät', 'description' => $faker->paragraph(10), 'admission' => 'free', 'google_event_id' => str_random(12)]));
$user->events()->save(Event::create(['scheduled_at' => Carbon::now()->subMonth(2), 'category_id' => rand(1, 6), 'title' => 'Gelöscht', 'subtitle' => 'Wird niemals stattfinden', 'description' => $faker->paragraph(10), 'admission' => 'free', 'google_event_id' => str_random(12), 'deleted_at' => Carbon::now()->subDays(7)]));
$events = Event::all();
foreach ($events as $event) {
$event->options()->save(EventOptions::create(['time_start' => '19:00', 'time_end' => '00:00', 'time_meal' => '18:00', 'shifts_bar' => rand(1, 2), 'shifts_tech' => rand(0, 2), 'shifts_door' => rand(0, 1), 'meal_servings' => rand(0, 15), 'misc' => 'Test test test']));
$user_id = rand(1, 2);
$event->shifts()->save(Shift::create(['user_id' => $user_id, 'type' => 'tech']));
$event->shifts()->save(Shift::create(['user_id' => $user_id == 1 ? 2 : 1, 'type' => 'bar']));
}
Model::reguard();
}
示例7: startup
public function startup()
{
$this->user = User::create(array('firstname' => 'Simon', 'email' => 'simon2@gmail.com'));
$this->event = Event::create(array('name' => 'The Red Wedding', 'uid' => $this->user->uid, 'location' => 'Winnipeg'));
$this->poll = Poll::create(array('eid' => $this->event->eid, 'polltype' => 'test_type'));
$this->lastPollOption = PollOption::max('oid');
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//user:1
//one day: 2
//long events:3
Event::create(array('name' => 'test1', 'user_id' => 1, 'calendar_id' => 2, 'startDate' => '2016-05-09 17:19:00', 'endDate' => '2016-05-09 20:52:00', 'length_hours' => 4, 'length_days' => 0, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test2', 'user_id' => 1, 'calendar_id' => 2, 'startDate' => '2016-05-09 14:50:00', 'endDate' => '2016-05-09 21:10:00', 'length_hours' => 7, 'length_days' => 0, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test3', 'user_id' => 1, 'calendar_id' => 2, 'startDate' => '2016-05-11 21:56:00', 'endDate' => '2016-05-12 00:00:00', 'length_hours' => 3, 'length_days' => 0, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test4', 'user_id' => 1, 'calendar_id' => 2, 'startDate' => '2016-05-18 00:00:00', 'endDate' => '2016-05-19 00:00:00', 'length_hours' => 24, 'length_days' => 0, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test5', 'user_id' => 1, 'calendar_id' => 2, 'startDate' => '2016-05-23 00:00:00', 'endDate' => '2016-05-23 19:45:00', 'length_hours' => 20, 'length_days' => 0, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test6', 'user_id' => 1, 'calendar_id' => 1, 'startDate' => '2016-05-18 18:56:00', 'endDate' => '2016-05-19 04:20:00', 'length_hours' => 10, 'length_days' => 2, 'allDay' => false, 'repeats' => false));
//*****Long Events***********
Event::create(array('name' => 'test7', 'user_id' => 1, 'calendar_id' => 3, 'startDate' => '2016-05-02 19:14:00', 'endDate' => '2016-05-04 22:57:00', 'length_hours' => 51.72, 'length_days' => 3, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test8', 'user_id' => 1, 'calendar_id' => 3, 'startDate' => '2016-05-12 21:36:00', 'endDate' => '2016-05-16 00:00:00', 'length_hours' => 75, 'length_days' => 4, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test9', 'user_id' => 1, 'calendar_id' => 3, 'startDate' => '2016-05-11 00:00:00', 'endDate' => '2016-05-16 00:00:00', 'length_hours' => 120, 'length_days' => 5, 'allDay' => false, 'repeats' => false));
Event::create(array('name' => 'test10', 'user_id' => 1, 'calendar_id' => 3, 'startDate' => '2016-05-20 00:00:00', 'endDate' => '2016-05-23 22:52:00', 'length_hours' => 95, 'length_days' => 4, 'allDay' => false, 'repeats' => false));
//*****************repetitions*************************************
//single reps calendar:4
//long reps calendar:5
Event::create(array('name' => 'rep1', 'user_id' => 1, 'calendar_id' => 4, 'startDate' => '2016-05-30 13:07:00 ', 'endDate' => ' 2016-05-30 23:39:00', 'length_hours' => 10.53, 'length_days' => 0, 'allDay' => false, 'repeats' => 1));
Event::create(array('name' => 'rep11', 'user_id' => 1, 'calendar_id' => 5, 'startDate' => '2016-08-09 13:13:00', 'endDate' => '2016-08-13 00:00:00', 'length_hours' => 83, 'length_days' => 4, 'allDay' => false, 'repeats' => 1));
Event::create(array('name' => 'rep13', 'user_id' => 1, 'calendar_id' => 5, 'startDate' => '2016-05-16 00:00:00', 'endDate' => '2016-05-18 16:18:00', 'length_hours' => 65, 'length_days' => 3, 'allDay' => false, 'repeats' => 1));
Event::create(array('name' => 'montly1', 'user_id' => 1, 'calendar_id' => 6, 'startDate' => '2016-05-03 00:00:00', 'endDate' => '2016-05-03 15:19:00', 'length_hours' => 16, 'length_days' => 0, 'allDay' => false, 'repeats' => 1));
Event::create(array('name' => 'year1', 'user_id' => 1, 'calendar_id' => 1, 'startDate' => '2016-05-03 00:00:00', 'endDate' => '2016-05-03 15:13:00', 'length_hours' => 15.22, 'length_days' => 0, 'allDay' => false, 'repeats' => 1));
Event::create(array('name' => 'montly long', 'user_id' => 1, 'calendar_id' => 6, 'startDate' => "2016-05-10 00:00:00", 'endDate' => '2016-05-13 00:00:00', 'length_hours' => 72, 'length_days' => 3, 'allDay' => false, 'repeats' => 1));
Event::create(array('name' => 'year long', 'user_id' => 1, 'calendar_id' => 5, 'startDate' => '2016-05-10 14:00:00', 'endDate' => '2016-05-13 00:00:00', 'length_hours' => 58, 'length_days' => 3, 'allDay' => false, 'repeats' => 1));
}
示例9: testEventDelete
public function testEventDelete()
{
$this->startUp();
$event = Event::create(array('name' => 'The Red Wedding', 'uid' => $this->user->uid, 'location' => 'Winnipeg'));
$event->delete();
$this->notSeeInDatabase('events', array('name' => 'TheRedWedding'));
}
示例10: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
User::create(['first_name' => 'null', 'last_name' => 'null', 'email' => 'null@null']);
Event::create(['name' => 'null', 'user_id' => 1, 'slug' => 'null', 'private' => 1, 'active' => 0]);
$styles = ['Rock', 'Hard Rock', 'Métal', 'Techno', 'House', 'Futur House', 'Rap', 'R&B', 'Pop', 'Pop Rock', 'Jazz', 'Blues'];
$this->createStyles($styles);
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(CreateEventRequest $req)
{
$input = $req->all();
// Makes sure chair_id enters database as an integer or null if left empty.
strcmp($input['chair_id'], "") == 0 ? $input['chair_id'] = null : ($input['chair_id'] = (int) $input['chair_id']);
// Ensures database times are always in UTC.
foreach ($input as $key => $value) {
// Ensures only time fields are changed.
if (!strpos($key, 'time')) {
continue;
}
// Converts time from PST to UTC.
$pst = new Carbon($value, 'America/Los_Angeles');
$utc = $pst->setTimezone('UTC');
// Sets date/time string back into values for database.
$input[$key] = $utc->toDateTimeString();
}
$input['creator_id'] = \Auth::id();
// Set creator ID by default
// Set default close time if needed
if (!isset($input['close_time'])) {
$input['close_time'] = $input['start_time'];
}
// Set default open time if needed
if (!isset($input['open_time'])) {
$input['open_time'] = Carbon::now();
}
// Create event
$event = Event::create($input);
return redirect()->action('EventsController@show', $event->slug);
}
示例12: create
public function create(Request $request)
{
if ($request->isMethod('get')) {
$this->data['items'] = Event::orderBy('created_at', 'desc')->get();
$this->data['questions'] = Question::get();
// return var_dump($this->data['questions']);
return view('pages.event.create', $this->data);
} elseif ($request->isMethod('post')) {
$data = $request->all();
$event = Event::create($request->all());
$user = User::where('positionid', 1)->get();
foreach ($user as $lala) {
$item = new Score();
$item->eventid = $event->id;
$item->score = 0;
$item->userid = $lala->id;
$item->save();
}
if ($event) {
if (array_key_exists('questions', $data)) {
$event->question()->sync($data['questions']);
$event->update(['enabled' => 1]);
}
return redirect('event');
} else {
return redirect('event');
}
}
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('events')->truncate();
Event::create(['tablename' => 'users', 'action' => 'create(创建)', 'user_id' => 2]);
Event::create(['tablename' => 'users', 'action' => 'store(保存)', 'user_id' => 2]);
Event::create(['tablename' => 'users', 'action' => 'destroy(删除)', 'user_id' => 2]);
}
示例14: store
/**
* Store a newly created event in the events table.
*
* @param \Illuminate\Http\Request $input
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$messages = ['date_format' => 'The start time does not match the format HH:MM:SS'];
//Validates the input from the create event page
$this->validate($request, ['name' => 'required|max:40', 'venue' => 'required|max:30', 'city' => 'required|max:30', 'price' => 'required|numeric', 'information' => 'required|max:255', 'description' => 'required', 'capacity' => 'required|numeric', 'date' => 'required|date', 'start_time' => 'required|date_format:H:i:s', 'end_time' => 'required|date_format:H:i:s', 'image' => 'image|required'], $messages);
//adds all the data from the create events page to the database in the events table
$name = $request->input('name');
$venue = $request->input('venue');
$city = $request->input('city');
$price = $request->input('price');
$information = $request->input('information');
$description = $request->input('description');
$capacity = $request->input('capacity');
$date = $request->input('date');
$start_time = $date . ' ' . $request->input('start_time');
$end_time = $date . ' ' . $request->input('end_time');
$image = 'image';
echo $end_time;
Event::create(['name' => $name, 'venue' => $venue, 'city' => $city, 'price' => $price, 'information' => $information, 'description' => $description, 'capacity' => $capacity, 'date' => $start_time, 'end_time' => $end_time, 'image' => $image]);
//gets the id of the event above and concats it to the file extension of the image uploaded.
$name = Event::latest()->first()->id . "." . Input::file('image')->getClientOriginalExtension();
//gets the event ID and concat on the imaage file extension that was uploaded
//moves and renames the image selected from a temp directory to the event_images folder as
Input::file('image')->move(public_path() . '/img/event_images', $name);
//moves the uploaded image from the tmp directory to a premanant one (/public/img/event_images) and renames it to <eventID>.<fileExt>
$image = Event::latest()->first();
//returns the latest event added to the table (the one just added above)
$image->image = $name;
//adds the image name from above to the image column of the latest event
$image->save();
//saves the above action
return redirect('events');
//redirects to events view when finished
}
示例15: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$u = User::create(['first_name' => 'test', 'last_name' => 'test', 'email' => 'test@test.fr', 'level' => 1]);
$u2 = User::create(['first_name' => 'test2', 'last_name' => 'test2', 'email' => 'test2@test.fr', 'level' => 1]);
$u3 = User::create(['first_name' => 'test3', 'last_name' => 'test3', 'email' => 'test3@test.fr', 'level' => 2]);
$e1 = Event::create(['name' => 'test event', 'user_id' => 3, 'slug' => 'test-event-1', 'date' => '2016-10-17', 'start' => '18:00:00', 'end' => '5:00:00']);
$e2 = Event::create(['name' => 'test event', 'user_id' => 1, 'slug' => 'test-event-2', 'date' => '2016-08-22', 'start' => '19:00:00', 'end' => '5:00:00']);
Event::create(['name' => 'test event', 'user_id' => 2, 'slug' => 'test-event-3', 'date' => '2017-01-07', 'start' => '18:00:00', 'end' => '5:00:00']);
$p1 = Playlist::create(['name' => 'Playlist principale !']);
$p2 = Playlist::create(['name' => 'The Playlist !']);
$p3 = Playlist::create(['name' => 'Playlist secondaire']);
Playlist::create(['name' => 'The Playlist !']);
$p1->styles()->sync([1, 2, 3]);
$p2->styles()->sync([1, 4]);
$p3->styles()->sync([1, 3, 5, 7]);
$e1->playlists()->sync([1, 3]);
$e2->playlists()->sync([2]);
Comment::create(['event_id' => 2, 'user_id' => 2, 'content' => 'Sooo goooood']);
Comment::create(['event_id' => 3, 'user_id' => 2, 'content' => 'Sooo goooood :D']);
Comment::create(['event_id' => 2, 'user_id' => 3, 'content' => 'Sooo goooood !!!']);
Video::create(['url' => '7l48bfQuJeE', 'artist' => 'Chill Bump', 'name' => 'Lost In The Sound', 'tags' => 'chill bump lost in the sound']);
Video::create(['url' => 'XxdPJvhQaMU', 'artist' => 'Chill Bump', 'name' => 'Water boycotter', 'tags' => 'chill bump water boycotter']);
Video::create(['url' => 'kWXAYDQ_K7k', 'artist' => 'Chill Bump', 'name' => 'The Memo', 'tags' => 'chill bump the memo']);
$pivot1 = $p1->videos()->sync([1, 3]);
$pivot2 = $p2->videos()->sync([2]);
$pivot3 = $p3->videos()->sync([1, 2, 3]);
News::create(['title' => 'news test', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 2, 'slug' => 'text-news-1']);
News::create(['title' => 'news test 2', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 3, 'slug' => 'text-news-2']);
Article::create(['title' => 'Article test 1', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 2, 'slug' => 'text-article-1']);
Article::create(['title' => 'Article test 2', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 3, 'slug' => 'text-article-2', 'event_id' => 2]);
}