本文整理汇总了PHP中app\Activity::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::join方法的具体用法?PHP Activity::join怎么用?PHP Activity::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::join方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show the index page for all activities.
* Responds to requests to GET /activities
*
* @return Response
*/
public function index()
{
$completedActivities = Activity::join('tasks', 'activities.activity_id', '=', 'tasks.activity_id')->where('tasks.status', 'completed')->lists('activities.activity_id')->toArray();
if (Auth::user()->is_admin) {
// No centre restriction if authenticated user is an admin
$upcoming = Activity::with('elderly')->whereNotIn('activity_id', $completedActivities)->where('datetime_start', '>', Carbon::now()->endOfDay())->oldest('datetime_start')->get();
$today = Activity::with('elderly')->whereNotIn('activity_id', $completedActivities)->whereBetween('datetime_start', [Carbon::today(), Carbon::now()->endOfDay()])->oldest('datetime_start')->get();
$past = Activity::with('elderly')->where(function ($query) use($completedActivities) {
$query->whereIn('activity_id', $completedActivities)->orWhere('datetime_start', '<', Carbon::today());
})->latest('datetime_start')->get();
} else {
// Show only activities that belong to the centre the authenticated user (non-admin) is in charge in
$upcoming = Activity::with('elderly')->ofCentreForStaff(Auth::user())->whereNotIn('activity_id', $completedActivities)->where('datetime_start', '>', Carbon::now()->endOfDay())->oldest('datetime_start')->get();
$today = Activity::with('elderly')->ofCentreForStaff(Auth::user())->whereNotIn('activity_id', $completedActivities)->whereBetween('datetime_start', [Carbon::today(), Carbon::now()->endOfDay()])->oldest('datetime_start')->get();
$past = Activity::with('elderly')->ofCentreForStaff(Auth::user())->where(function ($query) use($completedActivities) {
$query->whereIn('activity_id', $completedActivities)->orWhere('datetime_start', '<', Carbon::today());
})->latest('datetime_start')->get();
}
return view('activities.index', compact('upcoming', 'today', 'past'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$especificaciones = Spacification::leftJoin('activity_stage', 'activity_stage.id', '=', 'spacifications.activity_stage_id')->leftJoin('activities', 'activities.id', '=', 'activity_stage.activity_id')->orderBy('spacifications.name', 'DESC')->get(['spacifications.*', 'activities.name as actividad']);
$actividades = Activity::join('activity_stage', 'activity_stage.activity_id', '=', 'activities.id')->leftJoin('stages', 'stages.id', '=', 'activity_stage.stage_id')->orderBy('activities.name', 'ASC')->groupBy('activities.id')->get(['activity_stage.id as id', 'activities.name as name', 'stages.name as n_stage']);
return response()->json([$especificaciones, $actividades]);
}
示例3: exportGuest
public function exportGuest($id)
{
if (Gate::denies('download', Activity::class)) {
abort(403);
}
$records = Activity::join('activity_subtitles', 'activities.subtitle_id', '=', 'activity_subtitles.id')->join('activity_titles', 'activity_subtitles.title_id', '=', 'activity_titles.id')->select(['activities.date_of_activity', 'activities.barangay', 'activity_titles.title', 'activity_subtitles.subtitle', 'activities.day_of_activity', 'activities.venue_of_activity', 'activities.conducted_by', 'activities.remarks'])->where('activities.id', '=', $id)->get();
$recordsArray = [];
foreach ($records as $record) {
$recordsArray[] = ['date_of_activity', $record->date_of_activity];
$recordsArray[] = ['barangay', $record->barangay];
$recordsArray[] = ['title', $record->title];
$recordsArray[] = ['subtitle', $record->subtitle];
$recordsArray[] = ['day_of_activity', $record->day_of_activity];
$recordsArray[] = ['venue_of_activity', $record->venue_of_activity];
$recordsArray[] = ['conducted_by', $record->conducted_by];
$recordsArray[] = ['remarks', $record->remarks];
$recordsArray[] = [' ', ' '];
}
$records = Guest::join('activity_guest', 'activity_guest.guest_id', '=', 'guests.id')->select(['guests.last_name', 'guests.first_name', 'guests.age', 'guests.gender', 'guests.civil_status', 'guests.agency', 'guests.role', 'guests.email', 'guests.contact_number'])->where('activity_guest.activity_id', '=', $id)->orderBy('guests.last_name', 'asc')->orderBy('guests.first_name', 'asc')->get();
$recordsArray[] = ['last_name', 'first_name', 'age', 'gender', 'civil_status', 'agency', 'role', 'email', 'contact_number'];
foreach ($records as $record) {
$recordsArray[] = $record->toArray();
}
$now = Carbon::now('Asia/Manila');
$file_name = 'arp_activity_guest_attendance_' . $now->format('Ymd_His');
Excel::create($file_name, function ($excel) use($recordsArray) {
$excel->setTitle('ARP Activity Guest Attendance');
$excel->setDescription('List of ARP Activity Guest Attendance');
$excel->sheet('Activity Guest Attendance', function ($sheet) use($recordsArray) {
$sheet->fromArray($recordsArray, null, 'A1', false, false);
});
})->download('xlsx');
}