/**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $status = false;
     if ($this->method() == 'PATCH') {
         $routeAction = $this->route()->getAction();
         $routeParameters = $this->route()->parameters();
         $cid = false;
         if (isset($routeParameters['statusId'])) {
             $cid = $routeParameters['statusId'];
         } else {
             if (isset($routeParameters['one'])) {
                 $cid = $routeParameters['one'];
             }
         }
         $status = \App\Status::find($cid);
         if (!$status) {
             dd('error');
         }
     }
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'PUT':
             return ['name' => 'required|unique:statuses,name'];
         case 'PATCH':
             return ['name' => 'required|unique:statuses,name,' . $status->id];
         default:
             return [];
             break;
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param Request $request
  * @return mixed
  */
 public function edit(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:3', 'id' => 'required']);
     if (Status::find($request->input('id'))->update($request->except('_token', 'id'))) {
         return redirect()->back()->withSuccess('Status updated');
     } else {
         return redirect()->back()->withSError('Failed to update new status');
     }
 }
Beispiel #3
0
 public function verifySlot($slot)
 {
     $status = \App\Status::find(1);
     foreach ($slot->status as $stat) {
         $slot->status()->detach();
     }
     $status->slots()->attach($this);
     $this->updated_at = \Carbon\Carbon::now();
 }
 public function deleteDelete($statusId)
 {
     $status = \App\Status::find($statusId);
     if (!$status) {
         \Flash::error('Status not found');
         return redirect('statuses');
     }
     $status->delete();
     \Flash::success('Status Deleted');
     return redirect('statuses');
 }
 public function getLike($statusId)
 {
     $status = Status::find($statusId);
     if (!$status) {
         return redirect()->route('home');
     }
     if (!auth()->user()->isFriendsWith($status->user)) {
         return redirect()->route('home');
     }
     if (auth()->user()->hasLikedStatus($status)) {
         return redirect()->back();
     }
     //
     $like = $status->likes()->create([]);
     auth()->user()->likes()->save($like);
     return redirect()->back();
 }
 public function create()
 {
     $num_slots = \Input::get('num_slots');
     $check = \Auth::User()->name . '' . Carbon::now();
     for ($i = 0; $i < $num_slots; $i++) {
         $slot = new \App\Slot();
         $slot->slot_code = bcrypt($check);
         $slot->slot_rank = 0;
         $slot->user_id = \Auth::User()->id;
         $slot->save();
         $status = \App\Status::find(2);
         $status->slots()->attach($slot);
     }
     $user = \Auth::User();
     $name = $user->name;
     $slots = $user->slots()->get();
     return view('dashboard.user.profile')->with(['slots' => $slots, 'name' => $name, 'num_slots' => $num_slots]);
 }
 public function createTransaction()
 {
     $data = \Input::all();
     $user = \App\User::where('email', '=', $data['email'])->first();
     $slots = $user->slots()->where('transaction_id', '=', 0)->get();
     $amt = $data['amount'] / 500;
     $data = \Input::all();
     $stat = \App\Status::find(4);
     $transaction = new \App\Transaction();
     $transaction->transaction_number = $data['transaction_number'];
     $transaction->amount = $data['amount'];
     $transaction->save();
     $stat_id = 4;
     for ($i = 0; $i < $amt; $i++) {
         $transaction->slots()->save($slots[$i]);
         $slots[$i]->status()->detach();
         $stat->slots()->attach($slots[$i]);
     }
     return redirect('/valence');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $status = Status::find($id);
     $status->delete();
     return redirect('statuses');
 }
	                    			<td style="text-align:center">Discount</td>
	                    			<td style="text-align:center">Balance</td>
	                    			<td style="text-align:center">Total</td>
	                    			<td style="text-align:center">Status</td>
	                    			<td style="text-align:center">Actions</td>
	                    		</tr>
	                    	</tfoot>
	                    	<tbody>
	                    	<?php 
    $count = 1;
    ?>
	                    	@foreach($invoices as $invoice)
	                    		<tr>
	                    			<?php 
    $student = \App\Student::find($invoice->student_id);
    $status = \App\Status::find($invoice->status_id);
    ?>
	                    			<td style="text-align:center">{!! $count !!}</td>
	                    			<td><a href="{!! route('admin.students.show', array($student->id)) !!}">{!! $student->lname.' '.substr($student->mname,0 ,1).'. '.$student->fname !!}</a></td>
	                    			<td style="text-align:right">{!! number_format($invoice->amount , 2) !!}</td>
	                    			<td style="text-align:right">{!! number_format($invoice->discount , 2) !!}</td>
	                    			<td style="text-align:right">{!! number_format($invoice->balance , 2) !!}</td>
	                    			<td style="text-align:right">{!! number_format($invoice->total , 2) !!}</td>
		                            <td style="text-align:center">
		                              <div class="label {{ $invoice->status_id == 4? 'label-default': '' }}{{ $invoice->status_id == 8? 'label-success disabled': '' }}">
		                                {!! $status->status !!}
		                              </div>
		                            </td>
	                    			<td style="text-align:center">
					                  	<a href="{!! route('billing.invoices.student_invoice', array($invoice->student_id, $invoice->fee_schedule_code)) !!}" data-target="#customWidthModal" data-toggle="modal"  class="btn btn-sm btn-secondary">Invoice</a>
					                    <div class="btn-group right-dropdown">
 public function ver(Request $request, $id)
 {
     $data = Status::find($id);
     return view('sistemas.status.showStatus', compact('data', $data));
 }
 public function create()
 {
     $data = \Input::all();
     if ($data['transaction_number'] != '') {
         $amount_slot = $data['amount'] / 500;
         $transaction = new \App\Transaction();
         $transaction->transaction_number = $data['transaction_number'];
         $transaction->amount = $data['amount'];
         $transaction->save();
         $stat_id = 4;
     } else {
         $amount_slot = $data['amount'] / 500;
         $transaction = new \App\Transaction();
         $transaction->transaction_number = 'No Payment';
         $transaction->amount = 0;
         $transaction->save();
         $stat_id = 2;
     }
     $check = \Auth::User()->name . '' . Carbon::now();
     $user = \Auth::User();
     $limit = $user->limit;
     // dd($limit);
     if ($data['num_slots'] > $limit) {
         for ($i = 0; $i < $limit; $i++) {
             if ($i < $amount_slot) {
                 $slot = new \App\Slot();
                 $slot->slot_code = str_random(15);
                 $slot->slot_rank = 0;
                 $slot->user_id = \Auth::User()->id;
                 $transaction->slots()->save($slot);
                 $status = \App\Status::find($stat_id);
                 $status->slots()->attach($slot);
                 $user = \Auth::User();
                 $user->limit = $user->limit - 1;
                 $user->save();
                 $tree = new \App\Tree();
                 $tree->down1 = $slot->id - 1;
                 $tree->down2 = $slot->id - 2;
                 $tree->down3 = $slot->id - 3;
                 $tree->down4 = $slot->id - 4;
                 $tree->down5 = $slot->id - 5;
                 $tree->down6 = $slot->id - 6;
                 $tree->save();
                 $slot->tree_id = $tree->id;
                 $slot->save();
             } else {
                 $slot = new \App\Slot();
                 $slot->slot_code = str_random(15);
                 $slot->slot_rank = 0;
                 $slot->user_id = \Auth::User()->id;
                 $slot->save();
                 $status = \App\Status::find(2);
                 $status->slots()->attach($slot);
                 $user = \Auth::User();
                 $user->limit = $user->limit - 1;
                 $user->save();
                 $tree = new \App\Tree();
                 $tree->down1 = $slot->id - 1;
                 $tree->down2 = $slot->id - 2;
                 $tree->down3 = $slot->id - 3;
                 $tree->down4 = $slot->id - 4;
                 $tree->down5 = $slot->id - 5;
                 $tree->down6 = $slot->id - 6;
                 $tree->save();
                 $slot->tree_id = $tree->id;
                 $slot->save();
             }
         }
     } else {
         for ($i = 0; $i < $data['num_slots']; $i++) {
             if ($i < $amount_slot) {
                 $slot = new \App\Slot();
                 $slot->slot_code = str_random(15);
                 $slot->slot_rank = 0;
                 $slot->user_id = \Auth::User()->id;
                 $transaction->slots()->save($slot);
                 $status = \App\Status::find($stat_id);
                 $status->slots()->attach($slot);
                 $user = \Auth::User();
                 $user->limit = $user->limit - 1;
                 $user->save();
                 $tree = new \App\Tree();
                 $tree->down1 = $slot->id - 1;
                 $tree->down2 = $slot->id - 2;
                 $tree->down3 = $slot->id - 3;
                 $tree->down4 = $slot->id - 4;
                 $tree->down5 = $slot->id - 5;
                 $tree->down6 = $slot->id - 6;
                 $tree->save();
                 $slot->tree_id = $tree->id;
                 $slot->save();
             } else {
                 $slot = new \App\Slot();
                 $slot->slot_code = str_random(15);
                 $slot->slot_rank = 0;
                 $slot->user_id = \Auth::User()->id;
                 $slot->save();
                 $status = \App\Status::find(2);
                 $status->slots()->attach($slot);
                 $user = \Auth::User();
                 $user->limit = $user->limit - 1;
                 $user->save();
                 $tree = new \App\Tree();
                 $tree->down1 = $slot->id + 1;
                 $tree->down2 = $slot->id + 2;
                 $tree->down3 = $slot->id + 3;
                 $tree->down4 = $slot->id + 4;
                 $tree->down5 = $slot->id + 5;
                 $tree->down6 = $slot->id + 6;
                 $tree->save();
                 $slot->tree_id = $tree->id;
                 $slot->save();
             }
         }
     }
     $user = \Auth::User();
     $ranks = 0;
     $slots = $user->slots()->get();
     return view('dashboard.user.profile')->with(['slots' => $slots, 'num_slots' => $data['num_slots'], 'limit' => $limit, 'user' => $user, 'ranks' => $ranks]);
 }
Beispiel #12
0
 public function deleteStatus(Request $request)
 {
     $status_id = $request->get('status_id');
     $status = Status::find($status_id);
     $status->delete();
     return redirect()->back()->with('success_msg', 'Status was successfully deleted.');
 }