本文整理汇总了PHP中app\Activity::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::all方法的具体用法?PHP Activity::all怎么用?PHP Activity::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initData
private function initData()
{
$this->login();
factory(App\Activity::class, 50)->create();
factory(App\User::class, 10)->create();
factory(App\User::class, 'admin', 1)->create();
factory(App\Group::class, 25)->create()->each(function ($g) {
for ($i = 0; $i < 5; $i++) {
$g->users()->save(factory(App\User::class)->make(), ['role' => 'member']);
}
$g->users()->save(factory(App\User::class)->make(), ['role' => 'leader']);
});
factory(App\Event::class, 5)->create()->each(function ($event) {
$date = $event->time->startOfDay();
$endDate = $event->endDate;
do {
$occurrence = new EventOccurrence();
$occurrence->event_id = $event->id;
$occurrence->date = $date;
$occurrence->save();
$date->addWeek();
} while ($date < $endDate);
});
$faker = Faker\Factory::create();
$occurrences = EventOccurrence::all();
$activities = Activity::all()->toArray();
foreach ($occurrences as $occurrence) {
foreach ($faker->randomElements($activities, $faker->randomDigit) as $activity) {
$occurrence->activities()->attach($activity['id']);
}
}
}
示例2: performIntuitiveAssignment
public function performIntuitiveAssignment()
{
//Grab all the activities
$activities = Activity::all();
//pr0duce a tally 0f h0w many succesful applicati0ns each activity has received,
//in the f0rm 0f an ass0ciative array f0r th0se activities which have received
//m0re than 0 applicati0ns
$activityApplicationTally = array();
foreach ($activities as $activity) {
//get a c0unt 0f the number 0f succesful applicants f0r this activity
$numSuccesfulApplicants = $activity->getSuccessfulApplications->count();
if ($numSuccesfulApplicants > 0) {
$activityApplicationTally[$activity->id] = $numSuccesfulApplicants;
}
}
//fr0m http://www.w3schools.com/php/func_array_asort.asp
asort($activityApplicationTally, SORT_NUMERIC);
foreach ($activityApplicationTally as $activityID => $numSuccesfulApplicants) {
$numTutorsRequired = Activity::find($activityID)->quant_ppl_needed;
echo $numTutorsRequired;
//var_dump($activity);
}
//return $activityApplicationTally;
//return Activity::with('activityRequests');
}
示例3: index
public function index(Manager $fractal, ActivityTransformer $activityTransformer)
{
// show all
$records = Activity::all();
$collection = new Collection($records, $activityTransformer);
$data = $fractal->createData($collection)->toArray();
return $this->respond($data);
}
示例4: index
public function index()
{
$activities = Activity::all()->take(2);
$title = trans('default.home');
$locale = App::getLocale();
$homeText = HomeText::first();
$sliders = Slider::all();
return view('pages.index', compact('title', 'activities', 'locale', 'homeText', 'sliders'));
}
示例5: showActivitySelectView
public function showActivitySelectView()
{
$activities = Activity::all();
$activitiesByTaskGroups = $activities->groupBy('task_group');
$activitiesByTaskGroups = $activitiesByTaskGroups->map(function ($item, $key) {
return collect([$key => $item]);
});
$groups = Group::all();
$activitiesByAgeGroups = $activitiesByTaskGroups->groupBy(function ($item, $key) {
return $item->first()->first()->age_group;
});
return view('ActivityPlanning/activitySelection', compact('activitiesByAgeGroups', 'groups'));
}
示例6: getAllActivities
public function getAllActivities()
{
if (Auth::check()) {
# code...
if (Auth::user()->type == 2) {
# code...
$activities = Activity::all();
return view('subscription.subscribe', compact('activities'));
}
return redirect('/');
}
return redirect('/');
}
示例7: performIntuitiveAssignment
public function performIntuitiveAssignment()
{
$activities = Activity::all();
//create an ass0ciative array representing the am0unt 0f succesful applicatins
//there has been f0r each supp0rt activity, where the key is the activity's primary key
//in the database, and the value is the number 0f succesful applicati0ns.
$activityApplicationTally = array();
foreach ($activities as $activity) {
//c0unt the number 0f succesful applicati0ns f0r the activity
$numSuccesfulApplicants = $activity->getSuccessfulApplications->count();
//it is imp0ssible t0 intuitively assign phd students t0 the activity
//if the activity has had n0 succesful applicants, theref0re 0nly activities
//which have at least 1 succesful applicati0n will be added t0 the ass0ciative array
if ($numSuccesfulApplicants > 0) {
$activityApplicationTally[$activity->id] = $numSuccesfulApplicants;
}
}
//fr0m http://www.w3schools.com/php/func_array_asort.asp
//s0rt the ass0ciative array s0 that the activities with the fewest number 0f sucessful
//applicants will be pr0cessed first.
asort($activityApplicationTally, SORT_NUMERIC);
//pr0cess the activties in the assci0ative array 1 by 1.
$assignmentsMade = array();
//Ass0ciative array where key is the PHD student's ID in the database and
//the value is the id 0f the activity t0 which they were assigned
foreach ($activityApplicationTally as $activityID => $numSuccesfulApplicants) {
$numTutorsRequired = Activity::find($activityID)->quant_ppl_needed;
if ($numSuccesfulApplicants == $numTutorsRequired) {
$activity = Activity::find($activityID);
$successfulApplications = $activity->getSuccessfulApplications;
//assign the succesful applicants t0 all sessi0ns f0r the activity
foreach ($successfulApplications as $successfulApplication) {
$phdStudent = User::find($successfulApplication->user_id);
//line bel0w fr0m here https://laravel.com/docs/master/collections#method-pluck, why d0es this w0rk?
$phdStudentSessions = $phdStudent->sessions()->attach($activity->sessions->pluck('id')->all());
$assignmentsMade[$phdStudent->name] = $activity->title;
}
}
}
//foreach($assignments as $assignment) {
//var_dump($assignment);
//}
return view('intuitiveAssignmentResults')->with('assignmentsMade', $assignmentsMade);
//var_dump( $assignments);
//var_dump($phdStudentSessions);
//return $phdStudentSessions;
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
factory(App\Event::class, 5)->create()->each(function ($event) {
$date = $event->time->startOfDay();
$endDate = $event->endDate;
do {
$occurrence = new EventOccurrence();
$occurrence->event_id = $event->id;
$occurrence->date = $date;
$occurrence->save();
$date->addWeek();
} while ($date < $endDate);
});
$faker = Faker\Factory::create();
$occurrences = EventOccurrence::all();
$activities = Activity::all()->toArray();
foreach ($occurrences as $occurrence) {
foreach ($faker->randomElements($activities, $faker->randomDigit) as $activity) {
$occurrence->activities()->attach($activity['id']);
}
}
}
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$data = Activity::all();
return response()->json(json_encode($data));
}
示例10: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return Activity::all()->toJson();
}
示例11: getAll
public function getAll()
{
return \App\Activity::all();
}
示例12: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$activities = Activity::all();
$title = 'Administration des activités';
return view('admin.activities.index', compact('activities', 'title'));
}
示例13: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$activities = Activity::all();
return view('activities.index', compact('activities'));
}
示例14: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$activities = Activity::all();
return response()->json($activities);
}
示例15: apiIndex
public function apiIndex()
{
$activity = Activity::all();
return Response::json(['data' => $activity->toArray()], 200);
}