本文整理汇总了PHP中Gallery::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Gallery::create方法的具体用法?PHP Gallery::create怎么用?PHP Gallery::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gallery
的用法示例。
在下文中一共展示了Gallery::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Gallery::create([]);
}
}
示例2: testCreateRelatedMetaModelsWhenCreatesNewGallery
public function testCreateRelatedMetaModelsWhenCreatesNewGallery()
{
$attributes = ['post_content' => 'Dummy content.', 'post_title' => 'Dummy Title 1', 'post_date' => date('Y-m-d H:i:s'), 'pal_user_id' => 1, 'pal_gallery_id' => 1];
$gallery = Gallery::create($attributes);
$meta = $gallery->meta;
assertThat($meta, is(traversableWithSize(2)));
}
示例3: run
public function run()
{
$faker = Faker::create();
for ($i = 0; $i < 50; $i++) {
Gallery::create(array('title' => $faker->sentence($nbwords = 5), 'slug' => $faker->slug, 'content' => $faker->text, 'excerpt' => $faker->sentence, 'gallery_category_id' => $faker->numberBetween(1, 5)));
}
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$file = Input::file('image');
// your file upload input field in the form should be named 'file'
$destinationPath = public_path() . '/uploads';
$filename = $file->getClientOriginalName();
//$extension =$file->getClientOriginalExtension(); //if you need extension of the file
$uploadSuccess = Input::file('image')->move($destinationPath, $filename);
$RandNumber = rand(0, 9999999999.0);
if ($uploadSuccess) {
require_once 'PHPImageWorkshop/ImageWorkshop.php';
chmod($destinationPath . "/" . $filename, 0777);
$layer = PHPImageWorkshop\ImageWorkshop::initFromPath(public_path() . '/uploads/' . $filename);
unlink(public_path() . '/uploads/' . $filename);
$layer->resizeInPixel(400, null, true);
$layer->applyFilter(IMG_FILTER_CONTRAST, -16, null, null, null, true);
$layer->applyFilter(IMG_FILTER_BRIGHTNESS, 9, null, null, null, true);
$dirPath = public_path() . '/uploads/' . "gallery";
$filename = "_" . $RandNumber . ".png";
$createFolders = true;
$backgroundColor = null;
// transparent, only for PNG (otherwise it will be white if set null)
$imageQuality = 100;
// useless for GIF, usefull for PNG and JPEG (0 to 100%)
$layer->save($dirPath, $filename, $createFolders, $backgroundColor, $imageQuality);
chmod($dirPath . "/" . $filename, 0777);
}
//connect & insert file record in database
$gallery = Gallery::create(array('name' => Input::get('name'), 'title' => Input::get('title'), 'image' => $filename));
return View::make('gallery.manage');
}
示例5: run
public function run()
{
// Uncomment the below to wipe the table clean before populating
DB::table('wp_posts')->where('post_type', '=', 'gallery')->delete();
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Gallery::create(['ID' => (string) $index, 'post_author' => 1, 'post_content' => $faker->paragraph(), 'post_title' => $title = $faker->sentence(4), 'post_excerpt' => '', 'post_date' => $date = date("Y-m-d H:i:s"), 'post_date_gmt' => $date, 'post_status' => 'publish', 'post_name' => Str::slug($title), 'to_ping' => '', 'pinged' => '', 'post_modified' => $date, 'post_modified_gmt' => $date, 'post_content_filtered' => '', 'post_type' => 'gallery']);
}
}
示例6: postCreate
/**
* Handle post data and show our create form
*/
public function postCreate()
{
$error = false;
Gallery::create(['image' => Input::file('images')]);
if ($product = Products::create(Input::except('images', '_token'))) {
return Redirect::to(admin_path('products/edit/' . $product->id));
}
View::share('error', 'Couldn’t create your product.');
return self::getCreate();
}
示例7: createModels
/**
* Return Event and Gallery data
*/
public function createModels()
{
$eventData = array();
$galleryData = array();
// 1:1 data
$eventData['Title'] = $this->summary;
$eventData['StartDate'] = $this->start_dateTime;
$eventData['EndDate'] = $this->end_dateTime;
// Extract from summary format
$summary = trim($this->summary);
if (is_string($summary) && strlen($summary)) {
$summary_parts = explode(' - ', $summary);
if (count($summary_parts) === 2) {
$galleryData['Title'] = $summary_parts[0];
$eventData['ArtistName'] = $summary_parts[1];
}
}
// Create models
$event = Event::create()->update($eventData);
$gallery = Gallery::create()->update($galleryData);
return array('Event' => $event, 'Gallery' => $gallery);
}
示例8: moveImagesToGallery
public static function moveImagesToGallery($images = array(), $gallery_id = false)
{
if (!isset($images) || !is_array($images) || !count($images)) {
return $gallery_id;
}
## Find gallery
$gallery = $gallery_id ? Gallery::find($gallery_id) : null;
## If gallery not found - create her
if (!$gallery) {
$gallery = Gallery::create(array('name' => 'noname'));
}
## Get gallery ID
$gallery_id = $gallery->id;
## Move all images to gallery
foreach ($images as $i => $img_id) {
$img = Photo::find($img_id);
if (@$img) {
$img->gallery_id = $gallery_id;
#print_r($img);
$img->save();
}
}
return $gallery_id;
}
示例9: upload
public static function upload($url, $gallery = NULL, $title = '')
{
$img_data = @file_get_contents($url);
if (!$img_data) {
return false;
}
$tmp_path = storage_path(md5($url));
try {
file_put_contents($tmp_path, $img_data);
} catch (Exception $e) {
echo 'Error #' . $e->getCode() . ':' . $e->getMessage() . "<br/>\n";
echo 'In file: ' . $e->getFile() . ' (' . $e->getLine() . ')';
die;
}
$file = new \Symfony\Component\HttpFoundation\File\UploadedFile($tmp_path, basename($url));
## Check upload & thumb dir
$uploadPath = Config::get('site.galleries_photo_dir');
$thumbsPath = Config::get('site.galleries_thumb_dir');
if (!File::exists($uploadPath)) {
File::makeDirectory($uploadPath, 0777, TRUE);
}
if (!File::exists($thumbsPath)) {
File::makeDirectory($thumbsPath, 0777, TRUE);
}
## Generate filename
$fileName = time() . "_" . rand(1000, 1999) . '.' . $file->getClientOriginalExtension();
#echo $fileName;
## Get images resize parameters from config
$thumb_size = Config::get('site.galleries_thumb_size');
$photo_size = Config::get('site.galleries_photo_size');
## Get image width & height
$image = ImageManipulation::make($file->getRealPath());
$w = $image->width();
$h = $image->height();
if ($thumb_size > 0) {
## Normal resize
$thumb_resize_w = $thumb_size;
$thumb_resize_h = $thumb_size;
} else {
## Resize "by the smaller side"
$thumb_size = abs($thumb_size);
## Resize thumb & full-size images "by the smaller side".
## Declared size will always be a minimum.
$thumb_resize_w = $w > $h ? null : $thumb_size;
$thumb_resize_h = $w > $h ? $thumb_size : null;
}
## Resize thumb image
$thumb_upload_success = ImageManipulation::make($file->getRealPath())->resize($thumb_resize_w, $thumb_resize_h, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($thumbsPath . '/' . $fileName);
if ($photo_size > 0) {
## Normal resize
$image_resize_w = $photo_size;
$image_resize_h = $photo_size;
} else {
## Resize "by the smaller side"
$photo_size = abs($photo_size);
## Resize full-size images "by the smaller side".
## Declared size will always be a minimum.
$image_resize_w = $w > $h ? null : $photo_size;
$image_resize_h = $w > $h ? $photo_size : null;
}
## Resize full-size image
$image_upload_success = ImageManipulation::make($file->getRealPath())->resize($image_resize_w, $image_resize_h, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($uploadPath . '/' . $fileName);
## Delete original file
unlink($file->getRealPath());
## Gallery - none, existed, new
$gallery_id = 0;
if (is_int($gallery) && $gallery > 0) {
$gallery_id = $gallery;
} elseif (is_string($gallery)) {
$gal = Gallery::create(['name' => $gallery]);
$gallery_id = $gal->id;
}
## Create MySQL record
$photo = Photo::create(array('name' => $fileName, 'gallery_id' => $gallery_id, 'title' => $title));
return $photo;
}