/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, $this->rules); $point = new Point(); if ($point->storePoint($request)) { return redirect('program/activities/' . Session::get('activity'))->with('message', 'Point Added Successfully'); } else { return redirect('program/activities/' . Session::get('activity'))->with('message', 'Fail to Add Point'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($memberId, $pointId) { $point = Point::find($pointId); $member = Member::find($memberId); $member->update(['total_points' => $member->total_points - $point->point]); $point->Delete('set null'); return redirect()->action('MembersController@show', $memberId); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $member = Member::find($id); $birthday = Carbon::parse($member->birthday)->toFormattedDateString(); $points = Point::where('member_id', $id)->get(); $tambay_points = TambayPoint::where('member_id', $id)->get(); return view('members.show', compact('member', 'points', 'tambay_points', 'birthday')); }
public function signUp(Request $request) { $this->validate($request, ['firstname' => 'required|alpha', 'lastname' => 'required|alpha', 'idnumber' => 'required|numeric|digits:16', 'phone' => 'required|numeric|unique:users|digits:10', 'province' => 'required', 'district' => 'required', 'sector' => 'required', 'cell' => 'required', 'market' => 'required', 'category' => 'required', 'pin' => 'required|numeric|digits:4', 'pin-validation' => 'required|numeric|digits:4|same:pin']); $new = DB::table('personinfos')->insertGetId(['firstname' => $request->input('firstname'), 'lastname' => $request->input('lastname'), 'idnumber' => $request->input('idnumber')]); $id = DB::table('users')->insertGetId(['phone' => $request->input('phone'), 'password' => bcrypt($request->input('pin')), 'personinfo_id' => $new, 'market_id' => $request->input('market'), 'category_id' => $request->input('category'), 'status' => 0]); Point::create(['user_id' => $id, 'points' => 10]); return redirect()->route('index')->with('info', 'Account created and You can now sign In.'); }
public function random_point() { $points = \App\Point::all(); $random_key = array_rand($points->toArray(), 1); if ($random_key == 0) { $random_key = 1; } return $points[$random_key]->id; }
/** * Run the database seeds. */ public function run() { $loop = 50; $faker = $this->getFaker(); $countries = []; for ($i = 0; $i < 5; ++$i) { array_push($countries, $faker->word); } for ($i = 0; $i < $loop; ++$i) { $user = $this->getRandomUser(); $name = $faker->sentence(); $description = $faker->paragraph($nbSentences = $faker->randomDigitNotNull); $longitude = $faker->longitude; $latitude = $faker->latitude; $arr = ['name' => $name, 'description' => $description, 'longitude' => $longitude, 'latitude' => $latitude, 'country' => $countries[$faker->numberBetween(0, 4)], 'created_by' => $user, 'updated_by' => $user]; \App\Point::create($arr); } }
<h2 class="inside_headers_orange">топ пилотов</h2> <table style="width:100%;"> <?php $pilots = \App\Point::take(5)->orderBy('points', 'desc')->get(); ?> @foreach($pilots as $pilot) <tr><td width="90%">CMDR {{$pilot->user->name}}</td><td> <span class="white">{{$pilot->points}}</span></td></tr> @endforeach </table>
public function add() { $activeTab = Input::get('task_type_id') ? Input::get('task_type_id') : '1'; $task_types = TaskType::all(); $saleTypes = SaleType::all(); $user = Auth::user(); $point = intval(Input::get('point')); $task = Task::findOrFail(Input::get('task_id')); $pointAudit = new PointAudit(); $pointAudit->point = $point * $task->value; $pointAudit->user_id = $user->id; $pointAudit->company_id = $user->company_id; $pointAudit->date = new \DateTime(); $pointAudit->task_id = $task->id; $pointAudit->save(); $pointID = $user->id . date("mdY"); $pointEntity = Point::find($pointID); if ($pointEntity != null) { $pointEntity->points = $pointEntity->points + $point * $task->value; $pointEntity->update(); } else { $pointEntity = new Point(); $pointEntity->id = $pointID; $pointEntity->month = date("m"); $pointEntity->year = date("Y"); $pointEntity->user_id = $user->id; $pointEntity->company_id = $user->company_id; $pointEntity->points = $point * $task->value; $pointEntity->save(); } $message = 'You have ' . ($pointAudit->point > 0 ? 'added' : 'adjusted') . ' <strong> ' . intval($point) . ' points</strong> to <strong>' . $task->name . '</strong>.'; $today_total = $this->getTodaysStats(); $today_target = 140; $isErr = false; return view('myStat.add', compact('user', 'today_total', 'task_types', 'tasks', 'activeTab', 'isErr', 'message', 'today_target', 'saleTypes')); }
public function delete(Request $request) { Point::destroy($request->input('point_id')); }
public function getPoint($activityId, $programId = null) { $point = new Point(); $points = $point->getActivityPoint($activityId, $programId); return $points; }
public function getRank($programId) { $point = new Point(); $points = $point->getProgramRank($programId); return $points; }
/** * Update the values of a point. * * @param int $id The id of the point * * @return mixed JSON object with the point data */ public function update($id) { try { $point = Point::find($id); if (!$point->created_by == $this->user || !$this->user->role->name == 'admin') { return $this->respondRestricted('You did not create this point or you do not have the right role!'); } $point->name = Input::get('name', $point->name); $point->description = Input::get('description', $point->description); $point->latitude = Input::get('longitude', $point->longitude); $point->longitude = Input::get('latitude', $point->latitude); $point->country = Input::get('country', $point->country); $point->updated_at = date('Y-m-d H:i:s'); $point->updated_by = Auth::user()->id; if (!$point->save()) { return $this->respondInternalError('Could not save point!'); } return Fractal::item($point, new PointTransformer())->responseJson(200); } catch (Exception $e) { return $this->respondWithError(); } }
public function totalStats() { $points = \App\Point::orderBy('points', 'desc')->get(); return view($this->localeDir . 'cabinet.totalStats', compact('points')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit(BusStop $bus_stop) { $neighborhoods = Neighborhood::lists('name', 'id'); $points = Point::lists('id', 'id'); return view('bus_stops.edit', compact('bus_stop', 'neighborhoods', 'points')); }