本文整理汇总了PHP中Purchase::orderby方法的典型用法代码示例。如果您正苦于以下问题:PHP Purchase::orderby方法的具体用法?PHP Purchase::orderby怎么用?PHP Purchase::orderby使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Purchase
的用法示例。
在下文中一共展示了Purchase::orderby方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autouploadsaved
public function autouploadsaved()
{
//Image Upload
$purchasecheck = Purchase::orderby('id', 'DESC')->count();
if ($purchasecheck != 0) {
$purchase = Purchase::orderby('id', 'DESC')->find(Input::get('id'));
$docs = Document::orderby('id', 'DESC')->where('pr_id', $purchase->id)->first();
$pr_id = $purchase->id;
$doc_id = $docs->id;
} else {
$pr_id = 1;
$doc_id = 1;
}
foreach (Input::file('file') as $file) {
$rules = array('file' => 'required|mimes:png,gif,jpeg,jpg|max:900000000000000000000');
$validator = \Validator::make(array('file' => $file), $rules);
$destine = public_path() . "/uploads";
if ($validator->passes()) {
$ext = $file->guessClientExtension();
// (Based on mime type)
$ext = $file->getClientOriginalExtension();
// (Based on filename)
$filename = $file->getClientOriginalName();
$archivo = value(function () use($file) {
$filename = str_random(10) . '.' . $file->getClientOriginalExtension();
return strtolower($filename);
});
$archivo = value(function () use($file) {
$date = date('m-d-Y-h-i-s', time());
$filename = $date . "-" . $file->getClientOriginalName();
return strtolower($filename);
});
$attach = new Attachments();
$attach->doc_id = $doc_id;
$attach->data = $archivo;
$attach->saved = 1;
$attach->save();
$filename = $doc_id . "_" . $attach->id;
$file->move($destine, $archivo);
$target_folder = $destine;
$upload_image = $target_folder . "/" . $archivo;
$thumbnail = $target_folder . "/resize" . $archivo;
$actual = $target_folder . "/" . $archivo;
// THUMBNAIL SIZE
list($width, $height) = getimagesize($upload_image);
$newwidth = $width;
$newheight = $height;
while ($newheight > 525) {
$newheight = $newheight * 0.8;
$newwidth = $newwidth * 0.8;
}
$source = $upload_image;
$ext = strtolower($ext);
$thumb = imagecreatetruecolor($newwidth, $newheight);
if ($ext == "jpg" || $ext == "jpeg") {
$source = imagecreatefromjpeg($upload_image);
} elseif ($ext == "png") {
$source = imagecreatefrompng($upload_image);
} elseif ($ext == "gif") {
$source = imagecreatefromgif($upload_image);
} else {
continue;
}
// RESIZE
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// MAKE NEW FILES
if ($ext == "jpg" || $ext == "jpeg") {
imagejpeg($thumb, $thumbnail, 100);
} elseif ($ext == "png") {
imagepng($thumb, $thumbnail, 9);
} elseif ($ext == "gif") {
imagegif($thumb, $thumbnail, 100);
} else {
echo "An invalid image";
}
unlink($actual);
// FILE RENAMES
rename($thumbnail, $actual);
} else {
Session::put('imgerror', 'Invalid file.');
}
}
//End Image Upload
return redirect::back()->withInput();
}