本文整理汇总了PHP中app\Activity::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::create方法的具体用法?PHP Activity::create怎么用?PHP Activity::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
// Create a faker, add en_SG providers
$faker->addProvider(new Faker\Provider\en_SG\Address($faker));
$faker->addProvider(new Faker\Provider\en_SG\Enhanced($faker));
$faker->addProvider(new Faker\Provider\en_SG\Person($faker));
$faker->addProvider(new Faker\Provider\en_SG\PhoneNumber($faker));
$faker->seed(9876);
// Calling the same script twice with the same seed produces the same results
$durations = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180];
// Insert 30 dummy records
foreach (range(1, 30) as $index) {
$startDate = $faker->dateTimeBetween('-3 months', '3 months');
$startHour = ['08', '09', '10', '11', '13', '14', '15', '16'];
$startMin = ['00', '15', '30', '45'];
while (Carbon::instance($startDate)->dayOfWeek === Carbon::SUNDAY) {
$startDate = $faker->dateTimeBetween('-3 months', '3 months');
}
if ($startDate === Carbon::SATURDAY) {
$startHour = ['08', '09', '10', '11'];
}
$startTime = $faker->randomElement($startHour) . ":" . $faker->randomElement($startMin) . ":00";
$elderly = Elderly::with('centre')->find($faker->numberBetween(1, 15));
$staffList = $elderly->centre->staff->lists('staff_id')->toArray();
Activity::create(['datetime_start' => $startDate->format('Y-m-d') . " " . $startTime, 'expected_duration_minutes' => $faker->randomElement($durations), 'category' => 'transport', 'more_information' => $faker->optional(0.4, '')->sentence(10, true), 'location_from_id' => $elderly->centre_id, 'location_to_id' => $faker->numberBetween(4, 6), 'elderly_id' => $elderly->elderly_id, 'centre_id' => $elderly->centre_id, 'staff_id' => $faker->randomElement($staffList)]);
}
}
示例2: handle
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
$this->menu->updated_at = Carbon::now();
$this->menu->update($this->request->all());
Activity::create(['text' => $this->auth->linkedName() . ' updated menu named ' . $this->menu->linkedName(), 'user_id' => $this->auth->id]);
Session::flash('flash_message', 'You have updated menu!');
}
示例3: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('auth.login', function ($user, $remember) {
// Record user login
Activity::create(['subject_type' => 'User', 'subject_id' => '', 'event' => 'Logged In', 'user_id' => $user->id, 'ip' => Request::server('REMOTE_ADDR')]);
});
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(ActivityRequest $request)
{
Activity::create($request->all());
session()->flash('flash_message', 'Actividad creada correctamente.');
// Si flash_message_important esta presente, el mensaje no desaparece hasta que el usuario lo cierre
// session()->flash('flash_message_important', true);
return Redirect::to('actividades');
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
if ($activity = Activity::create($request->all())) {
return $activity->toJson();
} else {
return $this->response->error('Activity could not be created.', 404);
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(StoreActivityRequest $request)
{
if (Gate::denies('create', Activity::class)) {
abort(403);
}
Activity::create(['date_of_activity' => $request->date_of_activity, 'barangay' => $request->barangay, 'subtitle_id' => $request->subtitle_id, 'day_of_activity' => $request->day_of_activity, 'venue_of_activity' => $request->venue_of_activity, 'conducted_by' => $request->conducted_by, 'remarks' => $request->remarks]);
return redirect('/activity')->with('alert-success', 'The record has been saved!');
}
示例7: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//register log in DB
$dateBegin = new \DateTime();
$activity = Activity::concept(ConstDb::LOAD_CRL)->first();
if ($activity) {
$activity->date_begin = $dateBegin->format('Y-m-d H:i:s');
$activity->save();
} else {
Activity::create(['concept' => ConstDb::LOAD_CRL, 'date_begin' => $dateBegin->format('Y-m-d H:i:s')]);
}
//end log
$this->info('Begin: ' . date('H:i:s'));
$result = DB::connection('mysql_crl')->select($this->getQuery(true));
$rows = $result[0]->total;
$this->info("Total de filas: {$rows}");
$begin = 0;
$block = 10000;
$countBlock = 1;
$fCsv = storage_path('app/crl.csv');
if (file_exists($fCsv)) {
unlink($fCsv);
}
$fp = fopen($fCsv, 'w');
fputs($fp, "organization, from, year, quarter, month, total \n");
while ($rows > $begin) {
$result = DB::connection('mysql_crl')->select($this->getQuery(false, $begin, $block));
foreach ($result as $key => $value) {
$array = json_decode(json_encode($value), true);
$replace = ["\n", ',', ' '];
$replaceTo = ["", ';', ' '];
foreach ($array as $key => $value) {
$array[$key] = str_replace($replace, $replaceTo, $value);
}
fputs($fp, implode($array, ',') . "\n");
}
$this->info("End block {$countBlock}: " . date('H:i:s'));
$begin += $block;
$countBlock++;
}
fclose($fp);
$this->info('End export CSV: ' . date('H:i:s'));
Schema::drop('crl');
$db = env('MONGO_DATABASE');
$command = "mongoimport -d {$db} -c crl --type csv --file {$fCsv} --headerline";
shell_exec($command);
//register log in DB
$dateEnd = new \DateTime();
$activity = Activity::concept(ConstDb::LOAD_CRL)->first();
if ($activity) {
$activity->date_end = $dateEnd->format('Y-m-d H:i:s');
$activity->save();
} else {
Activity::create(['concept' => ConstDb::LOAD_CRL, 'date_end' => $dateEnd->format('Y-m-d H:i:s')]);
}
//end log
$this->info('End: ' . $dateEnd->format('H:i:s'));
}
示例8: recordActivity
public function recordActivity($event)
{
if (!Auth::id()) {
$user = ['id' => 1, 'name' => 'LENDA'];
} else {
$user = User::find(Auth::id())->toArray();
}
Activity::create(['loan_id' => $this->loan_id, 'user_id' => $user['id'], 'user' => $user['name'], 'subject_id' => $this->id, 'subject_type' => get_class($this), 'name' => $this->getActivityName($this, $event, $user)]);
}
示例9: fromProduct
public static function fromProduct($productId, $startTime)
{
$product = Product::findOrFail($productId);
$activity = Activity::create($product->toArray());
$activity->product_id = $product->id;
$activity->start_date = Carbon::createFromFormat('Y-m-d', $startTime);
$activity->thumb = $product->thumb;
$activity->banner = $product->banner;
$activity->save();
}
示例10: handle
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
$slug = Slug::create(['name' => $this->request->slug, 'slug_attribute_id' => self::SLUG_ATTRIBUTE_MENU]);
$this->request['slug_id'] = $slug->id;
$this->request['gallery'] = '';
// not yet implemented
$content = Content::create($this->request->all());
Activity::create(['text' => $this->auth->linkedName() . ' created new content named ' . $content->linkedName(), 'user_id' => $this->auth->id]);
Session::flash('flash_message', 'Your content has been created!');
}
示例11: update
public function update($id)
{
// save updated
$record = $this->records->find($id);
if (!$record) {
Activity::create(Input::all());
return $this->respond($record);
}
$record->fill(Input::all())->save();
return $this->respond($record);
}
示例12: recordActivity
/**
* Record activity for the model.
*
* @param string $event
* @return void
*/
public function recordActivity($event)
{
// $activity = new Activity();
//
// $activity->subject_id = $this->id;
// $activity->subject_type = get_class($this);
// $activity->name = $this->getActivityName($this, $event);
// $activity->subject_id = $this->id;
//
// Auth::user()->activity()->save($activity);
Activity::create(['subject_id' => $this->id, 'subject_type' => get_class($this), 'name' => $this->getActivityName($this, $event), 'user_id' => $this->user_id]);
}
示例13: recordActivity
public function recordActivity($event)
{
if (!empty($this->name)) {
$eventText = "{$event}: {$this->name}";
} else {
if (!empty($this->number)) {
$eventText = "{$event}: {$this->number}";
} else {
$eventText = $event;
}
}
Activity::create(['subject_type' => $this->getDisplaySingular(), 'subject_id' => $this->id, 'event' => $eventText, 'user_id' => Auth::user() ? Auth::user()->id : 0, 'ip' => Request::server('REMOTE_ADDR')]);
}
示例14: handle
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
$slug = Slug::create(['name' => $this->request->slug, 'slug_attribute_id' => self::SLUG_ATTRIBUTE_MENU]);
$this->request['slug_id'] = $slug->id;
$menu = new Menu($this->request->all());
$menu->generateOrder();
if ($menu->location_id == 0) {
$parent = Menu::findOrFail($menu->parent_id);
$menu->location_id = $parent->location_id;
}
$menu->save();
Activity::create(['text' => $this->auth->linkedName() . ' created new menu named ' . $menu->linkedName(), 'user_id' => $this->auth->id]);
Session::flash('flash_message', 'Your menu has been created!');
}
示例15: postStore
public function postStore()
{
if (Request::ajax()) {
$data = Input::get('data');
$i = 0;
foreach ($data as $key) {
Activity::create($data[$i]);
$i++;
if ($i == count($data)) {
return "OK";
}
}
}
}