本文整理汇总了PHP中Package::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::find方法的具体用法?PHP Package::find怎么用?PHP Package::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: from_upload
public static function from_upload(array $data, $key_mode = false)
{
$create = array();
$file = $data['file'];
$user = $data['user'];
if ($key_mode) {
$keys = collect(function ($key) {
return $key->key;
}, Pki::find('all', array('select' => '`key`', 'conditions' => array('user_id' => $user->id))));
$sig = $data['sig'];
if (!static::verify($file, $sig, $keys)) {
throw new NimbleException('Invalid package signature');
}
}
$package_data = new PackageExtractor($file);
if ($user->pear_farm_url() !== $package_data->data['channel']) {
throw new Exception('Package channel ' . $package_data->data['channel'] . ' does not match ' . $user->pear_farm_url());
}
$name = $package_data->data['name'];
$version = $package_data->data['version']['release'];
$stability = $package_data->data['stability']['release'];
if (!Package::exists(array('name' => $name, 'user_id' => $user->id))) {
$package = new Package(array('name' => $name, 'user_id' => $user->id, 'category_id' => Category::find_by_name('Default')->id));
} else {
$package = Package::find('first', array('conditions' => array('name' => $name, 'user_id' => $user->id)));
}
if (!$package->new_record && Version::exists(array('version' => $version, 'package_id' => $package->id))) {
throw new NimbleException("There is already a {$version}. You cannot replace existing packages. Please bump the version number and try again." . " You can delete a version from the web interface if needed.");
}
$package->move_uploaded_file($file, $version);
$type = VersionType::find_by_name($stability);
$package->versions = array(array('raw_xml' => $package_data->get_package_xml(), 'version' => $version, 'meta' => serialize($package_data->data), 'version_type_id' => $type->id, 'summary' => $package_data->data['summary'], 'description' => $package_data->data['description'], 'min_php' => $package_data->data['dependencies']['required']['php']['min']));
$package->save();
return $package;
}
示例2: set_default_side_bar
public function set_default_side_bar()
{
//$vs = Version::find('all', array('select' => 'distinct(package_id)', 'limit' => '0,5', 'order' => 'created_at DESC'));
$updated = Package::find('all', array('select' => '`packages`.*, MAX(`versions`.`created_at`) as ca', 'joins' => 'INNER JOIN `versions` on `versions`.`package_id` = `packages`.`id`', 'order' => 'ca DESC', 'limit' => '0,5', 'group' => '`packages`.`id`'));
$latest = Package::find('all', array('limit' => '0,5', 'order' => 'created_at DESC'));
$this->sidebar[0]['title'] = "New Packages";
$this->sidebar[0]['data'] = $latest;
$this->sidebar[1]['title'] = "Recently Updated";
$this->sidebar[1]['data'] = $updated;
}
示例3: set_default_side_bar
public function set_default_side_bar()
{
$this->latest = Package::find('all', array('limit' => '0,5', 'order' => 'created_at DESC'));
$this->sidepackage = $this->latest;
$this->sidebar[0]['title'] = "New Packages";
$this->sidebar[0]['content'] = $this->render_partial('layout/_package_list.php');
$this->updated = Package::find('all', array('limit' => '0,5', 'order' => 'updated_at DESC'));
$this->sidepackage = $this->updated;
$this->sidebar[1]['title'] = "Recently Updated";
$this->sidebar[1]['content'] = $this->render_partial('layout/_package_list.php');
}
示例4: edit_website
public function edit_website()
{
$this->layout = false;
$this->has_rendered = true;
$package = Package::find('first', array('conditions' => array('id' => $_GET['package_id'], 'user_id' => $this->user->id)));
if ($_POST['editorId'] == 'website') {
$p = Package::update($package->id, array('url' => $_POST['value']));
if ($p->saved) {
echo $p->url;
} else {
echo $package->url;
}
}
}
示例5: delete
public function delete()
{
$this->layout = '';
if (Request::ajax()) {
$package_id = Input::get('package_id');
$package = Package::find($package_id);
if (!empty($package) && Package::has_associated_members($package_id) == false) {
$package->delete();
echo 1;
} else {
echo "Package cannot be deleted.";
}
}
}
示例6: doPackage
function doPackage($file_name)
{
global $fp;
$path = explode(DIRECTORY_SEPARATOR, $file_name);
$file = array_pop($path);
$username = array_pop($path);
$package_split = explode('-', $file);
$name = $package_split[0];
try {
$user = User::find_by_username($username);
$package = Package::find('first', array('conditions' => array('user_id' => $user->id, 'name' => $name)));
$current = (int) $package->num_downloads;
$package->num_downloads = $current + 1;
$package->save();
} catch (Exception $e) {
fwrite($fp, NIMBLE_ENV . " log failed\n" . $e->getMessage() . "\n");
return;
}
}
示例7: delete
public function delete()
{
$this->login_user();
try {
$package = Package::find($_GET['id']);
$version = Version::find($_GET['version']);
} catch (NimbleRecordNotFound $e) {
$this->redirect_to('/');
}
if ($version->package_id == $package->id && $package->user_id == $this->user->id) {
$file = $package->file_path($version->version);
@unlink($file);
Nimble::flash('notice', "Version: {$version->version} was deleted");
$version->delete();
$this->redirect_to(url_for('PackageController', 'show', $package->user->username, $package->name));
} else {
$this->redirect_to('/');
}
}
示例8: load_release
private function load_release()
{
$this->package = Package::find('first', array('conditions' => array('name' => $_GET['name'], 'user_id' => $this->user->id)));
$date = DateHelper::from_db($this->package->updated_at);
$date = date(DATE_RFC822, $date);
$this->header("Last-Modified: {$date}");
$this->version = Version::find('first', array('conditions' => array('version' => $_GET['version'], 'package_id' => $this->package->id)));
$this->data = unserialize($this->version->meta);
}
示例9: getTimes
/**
* 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::select('SELECT id, booking_datetime AS bdate, strftime("%H:%M", booking_datetime) AS bdatetime FROM booking_datetimes WHERE strftime("%Y-%m-%d", booking_datetime)="' . $selectedDay . '"');
// 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) {
//get the start and end times of that time
$startTime = new DateTime($value->bdate);
$endTime = new DateTime($value->bdate);
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]);
}
}
return Response::make(View::make('getTimes')->with('selectedDay', $selectedDay)->with('availableTimes', $availableTimes), 200, array('Content-Type' => 'application/json'));
}
示例10: load_release
private function load_release()
{
$this->package = Package::find('first', array('conditions' => array('name' => $_GET['name'], 'user_id' => $this->user->id)));
$this->version = Version::find('first', array('conditions' => array('version' => $_GET['version'], 'package_id' => $this->package->id)));
$this->data = unserialize($this->version->meta);
}
示例11: attach_post
public function attach_post()
{
$this->layout = '';
$member_id = Request::segment(3);
$package_id = Input::get('package_id');
$package = Package::find($package_id);
$member = Member::find($member_id);
if (empty($member) || !is_object($member)) {
return Redirect::to('members')->with("error", "Member doesnt exists.");
}
$rules = array('package_id' => 'required|numeric');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('members/packages/' . $member_id . '/attach')->withErros($validator);
} else {
if (empty($package)) {
return Redirect::to('members/packages/' . $member_id)->with('error', 'Package doenst exists');
} else {
// IF MEMBER IS STILL HAVING THE SAME KIND OF PACKAGE
if (Memberpackage::still_has($member_id, $package_id) == false) {
$member_package = new Memberpackage();
$member_package->member_id = $member_id;
$member_package->package_id = $package_id;
// SET THE EXPIRATION DATE
if ($package->cycle->name == 'monthly') {
$expiration = strtotime(date("Y-m-d")) + 30 * 86400;
$member_package->expiration = date('Y-m-d', $expiration);
}
if ($package->cycle->name == 'annually') {
$expiration = strtotime(date("Y-m-d")) + 365 * 86400;
$member_package->expiration = date('Y-m-d', $expiration);
}
// REGISTRATION DATE
$member_package->registration = date("Y-m-d");
$member_package->status = 1;
$member_package->save();
return Redirect::to('members/packages/' . $member_id)->with('success', 'Package has been attached to the member.');
} else {
return Redirect::to('members/packages/' . $member_id . '/attach')->with('error', 'Sorry the package is still associated with the member.');
}
}
}
}
示例12: function
//
// {
// name: 'package-name',
// url: 'git-url'
// }
$app->get('/packages/:name', function ($name) use($app, $process) {
$package = Package::find(array('conditions' => array('name = ?', $name)));
$result = $process($package);
if (isset($result)) {
$package->update_attributes(array('hits' => $package->hits + 1));
$app->response()->header('Content-Type', 'application/json');
echo $result;
} else {
$app->response()->status(404);
}
});
// GET /packages/search/{parameters}
// < 200
//
// [{
// name: 'package-name',
// url: 'git-url'
// }]
$app->get('/packages/search/:name', function ($name) use($app, $process) {
$packages = Package::find('all', array('conditions' => array('name LIKE "%' . $name . '%"'), 'order' => 'name DESC'));
$result = $process($packages);
if (isset($result)) {
$app->response()->header('Content-Type', 'application/json');
echo $result;
}
});