本文整理汇总了PHP中app\Activity::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::where方法的具体用法?PHP Activity::where怎么用?PHP Activity::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show($id)
{
$activity = Activity::findOrFail($id);
$activity->load('members.user');
$activity->load('comments.user');
$user = [];
$joined = false;
$member = null;
if (Auth::check()) {
$user = User::findOrFail(Auth::user()->id);
$joined = ActivityMember::isJoined($id, $user->id);
$member = ActivityMember::where('activity_id', $id)->where('user_id', $user->id)->first();
if ($member != null) {
$member->load('activity');
}
}
$photos = Product::findOrFail($activity->product_id)->photos;
$members = $activity->members;
$activities = Activity::where('istop', 1)->orderBy('order_number')->take(5)->get();
$activities = $activities->filter(function ($item) use($activity) {
return $item->id != $activity->id;
});
$models = compact('activity', 'members', 'photos', 'joined', 'activities');
if (Auth::check()) {
$models['user'] = $user;
$models['member'] = $member;
}
return view('activity.show', $models);
}
示例2: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$activities = Activity::where('type', 'Run')->orderBy('start_date_local', 'desc')->get();
foreach ($activities as $activity) {
$activity->details = 0;
$activity->save();
}
}
示例3: byLoan
public function byLoan($id, Manager $fractal, ActivityTransformer $activityTransformer)
{
// show all
$records = Activity::where('loan_id', $id)->get();
$collection = new Collection($records, $activityTransformer);
$data = $fractal->createData($collection)->toArray();
return $this->respond($data);
}
示例4: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($id, $occId)
{
$eventOccurrence = EventOccurrence::where('event_id', $id)->findOrFail($occId);
//refaktoroikaa tää :D
$activities = Activity::where('age_group', $eventOccurrence->event->group->age_group)->whereNotIn('id', $eventOccurrence->activities()->get()->map(function ($item, $key) {
return $item->id;
}))->get();
return view('eventActivities', compact('eventOccurrence', 'activities'));
}
示例5: getActivityOfOneMonth
public function getActivityOfOneMonth($month, $year)
{
$date = Carbon::create($year, $month, 1, 0);
$initial_date = $date->toDateString();
$last_date = $date->addMonth()->subDay()->toDateString();
$trucks = Car::lists('name');
$activities = Activity::where('date', '>=', $initial_date)->where('date', '<=', $last_date)->get();
return $activities;
}
示例6: schedule
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')->hourly();
// Delete user activity older than 30 days
$schedule->call(function () {
Activity::where('created_at', '<', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
})->daily();
$schedule->command('bill:run')->daily();
}
示例7: index
public function index()
{
$activities = Activity::where('istop', 1)->where('states', 0)->orderBy('order_number')->get();
$guides = Guide::where('isbest', '=', 1)->orderBy('orders')->take(6)->get();
$topNotes = Note::topNotes()->with('user')->take(6)->get();
//$users = User::topUsers()->take(10)->get();
$adverts = Banner::where('tag', 'indexAdvert')->take(2)->get();
$banners = Banner::where('tag', 'indexBanner')->orderBy('orders')->get();
return view('index', compact('activities', 'guides', 'topNotes', 'adverts', 'banners'));
}
示例8: show
public function show($id)
{
$user = JWTAuth::parseToken()->authenticate();
$activity = Activity::where('id', $id)->where('user_id', $user['id'])->first();
if ($activity == null) {
return $this->respondError('NOT_FOUND', []);
} else {
return $this->respondSuccess('SUCCESS', Activity::transformOut($activity));
}
}
示例9: run
/**
* Run the database seeds.
* As a result of this database seeder script, 4 sessions will be created for the
* 'CM1103 Python Programming Lab' support activity, for which a single
* Demonstrator' role is assumed to be required
*
* @return void
*/
public function run()
{
//truncate the activities table so that the auto incrementing 'id' field starts counting from 1 again
DB::table('sessions')->truncate();
$activtiesCSVFile = new CsvFile(__DIR__ . '/_data/SessionsData.csv');
foreach ($activtiesCSVFile as $currentRow) {
//maybe make it w0rth with get(); s0meh0w
$supportActivity = Activity::where('title', '=', $currentRow[0])->first();
$Session = Session::create(['activity_id' => $supportActivity->id, 'date_of_session' => trim($currentRow[1]), 'start_time' => trim($currentRow[2]), 'end_time' => trim($currentRow[3]), 'location' => trim($currentRow[4])]);
}
}
示例10: handle
/**
* Handle the event.
*
* @param UnFeedableEvent $event
* @return void
*/
public function handle(UnFeedableEvent $event)
{
if ($event->gettype() == "CommentDeleted") {
$subject = $event->getSubject();
$lastActivity = Activity::where('subject_id', '=', $subject->id)->where('subject_type', '=', get_class($subject))->where('type', '=', 'CommentPosted')->last();
$lastActivity->delete();
} elseif ($event->gettype() == "SprintDeleted") {
$subject = $event->getSubject();
$lastActivity = Activity::where('subject_id', '=', $subject->id)->where('subject_type', '=', get_class($subject))->where('type', '=', 'SprintDeleted')->last();
$lastActivity->delete();
}
}
示例11: consulta
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function consulta(Request $request)
{
$proyecto_etapa = Project::where('projects.id', '=', $request->get('project_id'))->join('project_stage', 'project_stage.project_id', '=', 'projects.id')->join('stages', 'stages.id', '=', 'project_stage.stage_id')->where('stages.id', '=', $request->get('stage_id'))->get(['project_stage.id as id', 'stages.name as name']);
$actividad_etapa = Activity_Stage::where('activity_id', '=', $request->get('activity_id'))->where('stage_project_id', '=', $proyecto_etapa->last()->id)->get();
if (count($actividad_etapa) > 0) {
$especificaciones = Spacification::where('activity_id', '=', $actividad_etapa->last()->id)->get();
} else {
$especificaciones = '';
}
$etapa = stage::where('id', '=', $request->get('stage_id'))->first();
$proyecto = Project::where('id', '=', $request->get('project_id'))->first();
$actividad = Activity::where('id', '=', $request->get('activity_id'))->first();
return response()->json(['actividad_etapa' => $actividad_etapa, 'etapa' => $etapa->name, 'especificaciones' => $especificaciones, 'proyecto' => $proyecto->name, 'actividad' => $actividad->name, 'project_id' => $proyecto->id, 'stage_id' => $etapa->id, 'activity_id' => $actividad->id, 'project_stage_id' => $proyecto_etapa->first()->id]);
}
示例12: getActivity
public function getActivity($city_id = 0)
{
$res = ['response' => 'YES', 'status' => '1', 'data' => []];
if ($city_id == 0) {
$activitys = Activity::where('activity_active', '=', '1');
} else {
$activitys = Activity::whereRaw('( ( activity_active = 1 AND activity_city_id = 0 ) OR ( activity_active = 1 AND activity_city_id = ' . $city_id . ' ) )');
}
$activitys = $activitys->orderBy('activity_city_id', 'ASC')->orderBy('activity_sort', 'ASC')->get();
foreach ($activitys as $activity) {
$img = $activity->img()->first();
$res['data'][] = ['id' => $activity->activity_id, 'city_id' => $activity->activity_city_id, 'sort' => $activity->activity_sort, 'title' => $activity->activity_title, 'author' => $activity->activity_author, 'summary' => $activity->activity_summary, 'url' => MAPI_HOST . 'activity/' . $activity->activity_url, 'imgs' => [MAPI_IMG_HOST . $img->img_square, MAPI_IMG_HOST . $img->img_tiny, MAPI_IMG_HOST . $img->img_small, MAPI_IMG_HOST . $img->img_big, MAPI_IMG_HOST . $img->img_hd]];
}
return response()->json($res)->header('Content-Type', 'application/json');
}
示例13: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$key = $request->input('key');
$states = $request->input('states');
if (!$states) {
$states = 0;
}
$query = Activity::where('states', $states);
if ($key) {
$query->where(function ($query) use($key) {
$query->where('title', 'like', '%' . $key . '%')->orWhere('place', 'like', '%' . $key . '%');
});
}
$query->orderBy('order_number', 'asc');
$activities = $query->paginate(20);
return view('admin.activity.index', compact('key', 'activities', 'states'));
}
示例14: run
public function run()
{
$faker = Faker::create();
DB::table('activity_log')->delete();
// Gets an array with event IDs and an array with user IDs.
$cerf_ids = Cerf::all()->lists('id')->toArray();
$user_ids = User::all()->lists('id')->toArray();
for ($counter = 0; $counter < 30; $counter++) {
// Chooses random keys in both arrays.
$rand_cerf_id = $cerf_ids[array_rand($cerf_ids)];
$rand_user_id = $user_ids[array_rand($user_ids)];
// No two activity records should have the same user_id and cerf_id combination.
if (Activity::where('user_id', '=', $rand_user_id)->where('cerf_id', '=', $rand_cerf_id)->exists()) {
continue;
}
Activity::create(array('user_id' => $rand_user_id, 'cerf_id' => $rand_cerf_id, 'service_hours' => $faker->randomDigit, 'planning_hours' => $faker->randomDigit, 'traveling_hours' => $faker->randomDigit, 'admin_hours' => $faker->randomDigit, 'social_hours' => $faker->randomDigit, 'mileage' => $faker->randomDigit, 'notes' => $faker->paragraph));
}
}
示例15: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '1', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '2', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '4', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '5', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '6', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Sleep 7 Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '7', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Gentle Yoga')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '2', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Gentle Yoga')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Gentle Yoga')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '7', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Fun Run')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Fun Run')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '5', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '2', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '3', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '4', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '5', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Work Hours')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '6', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Happy Hour')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '6', 'activity_id' => $activity_id]);
$activity_id = \App\Activity::where('name', '=', 'Playground')->pluck('id');
DB::table('activities_dow')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'day_of_week' => '1', 'activity_id' => $activity_id]);
}