/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $user = User::find($id); $permissions = UserPermission::where('user_id', \Auth::id())->lists('package_id')->toArray(); $packages = Package::orderBy('name')->get(); return view('permissions.edit', compact('user', 'packages', 'permissions')); }
public function run() { DB::table('packages')->delete(); $collection = [['name' => 'None', 'level' => 0, 'price' => 0], ['name' => 'Basic', 'level' => 1, 'price' => 75000], ['name' => 'Enhanced', 'level' => 2, 'price' => 100000], ['name' => 'Supreme', 'level' => 3, 'price' => 150000]]; foreach ($collection as $record) { Package::create($record); } }
public function seed() { User::truncate(); User::create(['name' => 'Admin', 'email' => '*****@*****.**', 'password' => bcrypt('password')]); User::create(['name' => 'User', 'email' => '*****@*****.**', 'password' => bcrypt('password')]); User::create(['name' => 'New', 'email' => '*****@*****.**', 'password' => bcrypt('password')]); Package::create(['name' => 'BriansDBMT', 'namespace' => 'TomButts-BriansDBMT-Migrate', 'version' => 'dev-master']); }
/** * Delete package. * @param [int] $package_id [description] * @return [type] [description] */ public function deletePackage($package_id) { $extras = Extra::where('package_id', $package_id)->get(); foreach ($extras as $key => $value) { Extrafile::where('extra_id', $value->id)->where('is_attached', 1)->delete(); Extra::find($value->id)->delete(); } Package::find($package_id)->delete(); }
public function update($id) { // save updated $record = $this->records->find($id); if (!$record) { Package::create(Input::all()); return $this->respond($record); } $record->fill(Input::all())->save(); return $this->respond($record); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Package::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'store_id' => $this->store_id, 'order_id' => $this->order_id, 'order_date' => $this->order_date, 'courier_id' => $this->courier_id, 'shipment_date' => $this->shipment_date, 'delivery_date' => $this->delivery_date, 'arrived_in' => $this->arrived_in, 'is_disputed' => $this->is_disputed, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'tracking_id', $this->tracking_id])->andFilterWhere(['like', 'paid_with', $this->paid_with])->andFilterWhere(['like', 'refund_status', $this->refund_status])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'notes', $this->notes]); return $dataProvider; }
public function index(Request $request, $controller) { $controller = $this->getControllerName($controller); try { $namespace = $request->segment(2); $integration = new Integrate($controller); $integration->sendData($request->all()); $html = $integration->getHtml(); $packageName = Package::where('namespace', $namespace)->first(); $packageName = $packageName->name; return view('package.index', compact('html', 'packageName')); } catch (\Exception $e) { return response($e->getMessage(), 404); } }
/** * Execute the console command. * * @param Client $client * * @return mixed */ public function handle(Client $client) { // Basic setup for offset-building $maxNumPackages = 5; $totalNumPackages = Package::count(); $numResultSets = ceil($totalNumPackages / $maxNumPackages); // Paginate through results for ($numResultSet = 0; $numResultSet < $numResultSets; $numResultSet++) { // Get current result set $packages = Package::skip($numResultSet * $maxNumPackages)->take($maxNumPackages)->get(); // Go through current result set foreach ($packages as $package) { $this->info("Fetching package information for {$package->name}..."); // Get package info $packageInfo = $this->getPackageInfo($package->name, $client); // Validate if ($packageInfo === false) { $this->warn('Package skipped.'); continue; } // Check if it is a GitHub repository if (!$this->isGitHubRepository($packageInfo->package->repository)) { $this->warn("Package {$packageName} is NOT a GitHub repository and will be skipped!"); continue; } // Get GitHub package name $packageName = $this->getPackageNameFromUrl($packageInfo->package->repository); $this->info("Fetching contributors for {$packageName}..."); // Get contributors on GitHub of this repository $contributors = $this->getContributors($packageName, $client); // Validate if ($contributors === false) { $this->warn('Package skipped.'); continue; } // Go through contributors foreach ($contributors as $contributor) { // Find or create contributor $contributor = Contributor::firstOrCreate(['name' => $contributor]); // Attach contributor to current package if it isn't yet if (!$package->contributors->contains($contributor->contributor_id)) { $package->contributors()->attach($contributor->contributor_id); } } $this->info('OK'); } } }
/** * Retrieves all appointments and returns them * in fullCalendar expected JSON */ public function GetAllAppointments() { $appointments = Appointment::all(); $calendarAppointments = array(); foreach ($appointments as $a) { $customer = Customer::find($a['customer_id']); $customer = $customer->first_name . ' ' . $customer->last_name; $package = Package::find($a['appointment_type']); $startDate = date_create($a['appointment_datetime']); $endDate = date_create($a['appointment_datetime']); $time = (string) $package->package_time . ' hours'; $endDate = date_add($endDate, date_interval_create_from_date_string($time)); $event = array('id' => $a['id'], 'title' => 'Appointment with ' . $customer, 'start' => $startDate->format('Y-m-d\\TH:i:s'), 'end' => $endDate->format('Y-m-d\\TH:i:s')); array_push($calendarAppointments, $event); } return response()->json($calendarAppointments); }
/** * Execute the console command. * * @param Client $client * * @return mixed */ public function handle(Client $client) { try { // Get packages from packagist $packages = $client->request('GET', $this->packagesUrl); } catch (\Exception $e) { $this->error($e->getMessage()); return false; } // Validate JSON $packages = json_decode($packages->getBody()->getContents(), true); if (json_last_error() > 0 || !isset($packages['packageNames'])) { $this->error('Unfortunately the packages could not be fetched. Please try again later.'); return false; } $packages = $packages['packageNames']; foreach ($packages as $package) { Package::firstOrCreate(['name' => $package]); } }
/** * View Function to edit package information * @param int $package_id * @return view */ public function editPackage($package_id) { return view('admin/packages/editPackage', ['package' => Package::find($package_id)]); }
public function get_packagechange() { $count = PackageChange::all()->count(); $package_changes = PackageChange::all(); $packages = Package::all(); if ($count == 0) { return View('exam.main.admin.packagechange')->withtitle('Admin | Dashboard')->withpackages($packages); } else { return View('exam.main.admin.packagechange')->withtitle('Admin | Dashboard')->withpackages($packages)->withpackage_changes($package_changes); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $this->validation_rules($request); $packageUpdate = $request->input(); $package = Package::find($id); $package->update($packageUpdate); Session::flash('flash_message', 'Data Paket layanan berhasil diupdate!'); return redirect('admin/package'); }
/** * Finds the Package model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Package the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Package::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo Html::a('New', ['create'], ['class' => 'btn btn-success']); ?> <?php echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> <?php echo Html::a('Import Store', ['import'], ['class' => 'btn btn-warning']); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'store_number', 'value' => empty($model->store_number) ? "<i>N/A</i>" : $model->store_number . " [" . Html::a('AliExpress Store Page', 'http://www.aliexpress.com/store/' . $model->store_number, array('target' => '_blank')) . "]", 'format' => 'raw'], 'name', 'location', 'since', 'notes:ntext', ['attribute' => 'created_by', 'value' => $model->createdByUser->username, 'format' => 'text'], 'created_at', ['attribute' => 'updated_by', 'value' => $model->updatedByUser->username, 'format' => 'text'], 'updated_at']]); ?> <?php $dataProvider = new ActiveDataProvider(['query' => \app\models\Package::find()->innerJoin('store', '`store`.`id` = `package`.`store_id`')->where(['store.id' => $model->id])->with('store')->orderBy('id DESC'), 'pagination' => ['pageSize' => -1]]); echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'order_id', 'description', 'price', 'order_date', 'shipment_date', 'delivery_date', 'is_disputed', ['attribute' => 'status', 'value' => function ($model) { return "<b style='color:red;'>" . $model->status . "</b>"; }, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:70px;'], 'header' => 'Actions', 'template' => '{view}', 'urlCreator' => function ($action, $model, $key, $index) { if ($action === 'view') { $url = '/package/view/' . $model->id; return $url; } }]]]); ?> </div>
/** * Relationship with Package */ public function getPackage() { return $this->hasMany(Package::className(), ['store_id' => 'id']); }
public function get_index() { $package = Package::all()->sortby('price'); return view('exam.main.index')->with('packages', $package); }
?> <?php $dataProvider = new ActiveDataProvider(['query' => \app\models\Package::find()->innerJoin('courier', '`courier`.`id` = `package`.`courier_id`')->where(['courier.id' => $model->id])->orderBy('id DESC'), 'pagination' => ['pageSize' => -1]]); echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'order_id', 'description', 'order_date', 'shipment_date', 'tracking_id', 'delivery_date', 'arrived_in', ['attribute' => 'is_disputed', 'value' => function ($model) { $is_disputed_calc = $model->is_disputed == 1 ? 'Yes' : 'No'; return "<b style='color:darkblue;'>" . $is_disputed_calc . "</b>"; }, 'format' => 'raw'], ['attribute' => 'status', 'value' => function ($model) { return "<b style='color:red;'>" . $model->status . "</b>"; }, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:70px;'], 'header' => 'Actions', 'template' => '{view}', 'urlCreator' => function ($action, $model, $key, $index) { if ($action === 'view') { $url = '/package/view/' . $model->id; return $url; } }]]]); ?> <h3>Items in transit</h3> <div style="background-color: #f1f1f1"> <?php $trackingIDs = \app\models\Package::find()->innerJoin('courier', '`courier`.`id` = `package`.`courier_id`')->where(['courier.id' => $model->id, 'package.status' => 'Awaiting delivery'])->orderBy('id DESC')->all(); if ($trackingIDs != false) { foreach ($trackingIDs as $trackingID) { echo $trackingID->tracking_id . "<br />"; } } ?> </div> </div>
public function addCoupon($book_id) { $book = Book::find($book_id); $linkfilecss = 'add_coupon.css'; $packages = Package::getPackageBelongBook($book_id); return view('frontend.author.add_coupon', compact('book', 'linkfilecss', 'packages')); }
if ($data->is_disputed != 1 && $data->shipment_date == "0000-00-00") { $details = ""; } else { if ($data->is_disputed != 1 && $data->delivery_date != "0000-00-00" && $data->shipment_date != "0000-00-00") { $details = " - received on " . $data->delivery_date; } else { if ($data->is_disputed != 1 && $data->delivery_date == "0000-00-00" && $data->shipment_date != "0000-00-00") { $details = " - en route since " . \app\models\Package::getDaysElapsed($data->shipment_date); } else { $details = ""; } } } } return "<b style='color:red;'>" . $data->status . "</b>" . $details; }, 'filter' => Html::activeDropDownList($searchModel, 'status', ArrayHelper::map(\app\models\Package::find()->orderBy(['status' => SORT_ASC])->addGroupBy(['status'])->asArray()->all(), 'status', 'status'), ['class' => 'form-control', 'prompt' => 'Select...']), 'options' => array('width' => 160), 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:105px;'], 'template' => '{view} {shipped} {received} {update} {delete}', 'buttons' => ['shipped' => function ($url, $model) { if ($model->shipment_date == "0000-00-00") { $shippedButtonClass = "glyphicon-unchecked"; $shippedButtonTitle = "Mark item as shipped?"; } else { $shippedButtonClass = "glyphicon-check"; $shippedButtonTitle = "Mistake? Mark item not shipped"; } return Html::a('<span class="glyphicon ' . $shippedButtonClass . '"></span>', $url, ['title' => Yii::t('yii', $shippedButtonTitle), 'data-confirm' => Yii::t('yii', 'Are you sure you want to mark this item?'), 'data-method' => 'post', 'data-pjax' => '0']); }, 'received' => function ($url, $model) { if ($model->delivery_date == "0000-00-00" && $model->shipment_date == "0000-00-00") { $receivedButtonClass = "glyphicon-ban-circle"; $receivedButtonTitle = "Not yet shipped"; } else { if ($model->delivery_date == "0000-00-00" && $model->shipment_date != "0000-00-00") { $receivedButtonClass = "glyphicon-heart-empty";
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $package = Package::find($id); $package->delete(); return redirect('/packages')->withMessage('<i class="glyphicon glyphicon-ok"></i> This package has been deleted'); }
public function run() { Eloquent::unguard(); Package::create(array('package_name' => 'Package 1', 'package_price' => '135', 'package_time' => '8', 'package_description' => 'This is the first package and a description of it')); Package::create(array('package_name' => 'Package 2', 'package_price' => '175', 'package_time' => '2', 'package_description' => 'This is the second package and a description of it')); }
/** * [getPackageBelongBook description] * @param [type] $book_id [description] * @return [type] [description] */ public static function getPackageBelongBook($book_id) { $packages = Package::where('book_id', '=', $book_id)->get(); return $packages; }
@extends('templates.main') @section('content') <div class="pricingPackages"> <div class="photoTop2"> <h1>PRICING</h1> </div> <p>Digital Packages<br> (edited digital files on disc)</p> @if(Auth::check()) <p style="color:red;">CLICK ON TEXT TO EDIT <i class="fa fa-pencil"></i></p> @endif <?php $packages = \App\Models\Package::paginate(6); $packages->setPath(""); ?> <div class="wrap5"> @foreach($packages as $package) <div class="package"> <div class="topHeading"><h2 data-field="heading" data-packageid="{{$package->id}}">{{$package->heading}} </h2></div> <div class="img"><img src="{{asset('img/'.$package->picture)}}" alt=""></div> <div class="price"> <p data-field="price" data-packageid="{{$package->id}}">{{$package->price}}</p> </div> <div class="content"><p data-field="description" data-packageid="{{$package->id}}">Price Includes<br><br> {{$package->description}}</p> </div> @if(Auth::check()) {!! Form::open(["url"=>"pricingPackages/".$package->id, "method"=>"delete"]) !!} {!! Form::submit("Delete" , array('class'=>'delete')) !!} {!! Form::close() !!}
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $package = \App\Models\Package::find($id); $package->delete(); return redirect('pricingPackages'); }
/** * Function to retrieve times available for a given date * * View is returned in JSON format * **/ public function getTimes() { // We get the data from AJAX for the day selected, then we get all available times for that day $selectedDay = Input::get('selectedDay'); $availableTimes = DB::table('booking_datetimes')->get(); // We will now create an array of all booking datetimes that belong to the selected day // WE WILL NOT filter this in the query because we want to maintain compatibility with every database (ideally) // PSEUDO CODE // Get package duration of the chosen package $package = Package::find(Session::get('packageID')); $packageTime = $package->package_time; // For each available time... foreach ($availableTimes as $t => $value) { $startTime = new DateTime($value->booking_datetime); if ($startTime->format("Y-m-d") == $selectedDay) { $endTime = new DateTime($value->booking_datetime); date_add($endTime, date_interval_create_from_date_string($packageTime . ' hours')); // Try to grab any appointments between the start time and end time $result = Appointment::timeBetween($startTime->format("Y-m-d H:i"), $endTime->format("Y-m-d H:i")); // If no records are returned, the time is okay, if not, we must remove it from the array if ($result->first()) { unset($availableTimes[$t]); } } else { unset($availableTimes[$t]); } } return response()->json($availableTimes); }