本文整理汇总了PHP中app\Photo::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::save方法的具体用法?PHP Photo::save怎么用?PHP Photo::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Photo
的用法示例。
在下文中一共展示了Photo::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multiple_upload
public function multiple_upload(Request $request)
{
/*
* Tests incoming files to make sure there's no duplicates in db
*/
// getting all of the post data
$files = Input::file('userfile');
// Making counting of uploaded images
$file_count = count($files);
// start count how many uploaded
$uploadcount = 0;
$hash_type = 'md5';
// don't change this on an existing database!
$filepath = 'img/';
$thumbpath = 'img/thumbs/';
foreach ($files as $file) {
if (in_array(exif_imagetype($file), array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
$filename = $file->getClientOriginalName();
$extension = strtolower($file->getClientOriginalExtension());
$photo = new Photo();
//photo db object
$photo->filename = $filename;
$photo->extension = $extension;
$photo->save();
$currImg = Image::make($file);
$currFilePath = $filepath . $photo->id . "." . $extension;
$currImg->orientate()->save($currFilePath);
// saving the actual file
$hashcheck = hash_file($hash_type, $currFilePath);
$hasDuplicate = Photo::where('hash', $hashcheck)->first();
if ($hasDuplicate) {
// rollback if duplicate found
File::delete($currFilePath);
$photo->delete();
} else {
$currImg->heighten(174)->save($thumbpath . $photo->id . "_thumb" . "." . $extension);
$photo->hash = hash_file($hash_type, $currFilePath);
// hash generated after we save the file
$photo->notes = $request->input('note');
$photo->image_subject = "Rosemary";
$photo->save();
$uploadcount++;
}
$currImg->destroy();
// free up memory
}
}
return $file_count - $uploadcount;
}
示例2: updateAlbum
public function updateAlbum(Request $request)
{
$albums = json_decode($request->all()['albums'], true);
$len = count($albums);
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
Album::truncate();
Photo::truncate();
Album::reindex();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
foreach ($albums as $a) {
$album = new Album();
$album->album_id = $a['id'];
$album->name = $a['name'];
$album->created_time = $a['created_time'];
$album->save();
$photos = $a['photos']['data'];
foreach ($photos as $p) {
$photo = new Photo();
$photo->album_id = $album->id;
$photo->photo_id = $p['id'];
$photo->source = $p['source'];
$photo->save();
}
}
return '1';
}
示例3: postCreate
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function postCreate(PhotoRequest $request)
{
$photo = new Photo();
$photo->user_id = Auth::id();
$photo->language_id = $request->language_id;
$photo->name = $request->name;
$photo->photo_album_id = $request->photo_album_id;
$photo->description = $request->description;
$photo->slider = $request->slider;
$photo->album_cover = $request->album_cover;
$picture = "";
if ($request->hasFile('image')) {
$file = $request->file('image');
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$picture = sha1($filename . time()) . '.' . $extension;
}
$photo->filename = $picture;
$photo->save();
if ($request->hasFile('image')) {
$photoalbum = PhotoAlbum::find($request->photo_album_id);
$destinationPath = public_path() . '/appfiles/photoalbum/' . $photoalbum->folder_id . '/';
$request->file('image')->move($destinationPath, $picture);
$path2 = public_path() . '/appfiles/photoalbum/' . $photoalbum->folder_id . '/thumbs/';
Thumbnail::generate_image_thumbnail($destinationPath . $picture, $path2 . $picture);
}
}
示例4: update
public function update(Request $request, Blog $blog, BlogPost $blogPost, Photo $photo)
{
// extra validation specific to adding an inscription
$validator = $this->requireInscription($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
$photo->inscription_title = $request['inscription_title'];
$photo->inscription_content = $request['inscription_content'];
$photo->save();
return redirect(route('blog.blogPost.edit', ['blog' => getUrlForThisName($blog), 'blogPost' => getUrlForThisName($blogPost)]));
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$categories = Category::all();
foreach ($categories as $category) {
$filename = sprintf('%s-Tour.jpg', str_replace([' ', '/'], '-', $category->name));
$newPhoto = new Photo();
$newPhoto->path = $filename;
$newPhoto->imageable_id = $category->id;
$newPhoto->imageable_type = 'App\\Category';
$newPhoto->save();
}
}
示例6: update
public function update(Request $request, $year, $month, $day)
{
$date = $this->createDate($year, $month, $day);
$file = $request->file('photo');
if (is_null($file)) {
abort(400);
}
$photo = new Photo($date);
$image = Image::make($file);
$photo->save($image);
return response(json_encode($photo->toArray()), 201)->header('Content-Type', 'application/json');
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$packages = Package::all();
foreach ($packages as $package) {
$filename = sprintf('%s-Tour.jpg', str_replace(' ', '-', $package->name));
$newPhoto = new Photo();
$newPhoto->path = $filename;
$newPhoto->imageable_id = $package->id;
$newPhoto->imageable_type = 'App\\Package';
$newPhoto->save();
}
}
示例8: uploadPhotos
public function uploadPhotos(Request $request)
{
//adding image during image intervention
$image = Input::file('image');
$filename = time() . '-' . $image->getClientOriginalName();
$path = $image->move('images\\photos', $filename);
// Image::make($image->getRealPath())->resize('600','400')->save($path);
$photo = new Photo();
$photo->photo_name = $filename;
$photo->album_id = $request->input('album_id');
$photo->save();
return redirect('profile');
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//Here we will ceate a new object of model file called
$photo = new Photo();
$photo->name = $request->name;
//$photo->path = $request->file("photoFile");
$photo->user_id = $request->user_id;
//I need to copy the file a give it some valid name
$photo->path = "Photo" . $photo->user_id . ".png";
$request->file("photoFile")->move(storage_path() . "/" . $photo->path);
$photo->save();
return redirect('/photo');
}
示例10: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$photoDirectory = env('BH_PHOTO_DIRECTORY');
$fileExtension = $this->file->getClientOriginalExtension();
$fileName = str_random(10) . '.' . $fileExtension;
$image = \Image::make($this->file->getRealPath());
$image->resize(800, 800);
$image->save($photoDirectory . '/photo_files/normal/' . $fileName);
$image->resize(100, 100);
$image->save($photoDirectory . '/photo_files/thumbnail/' . $fileName);
$photo = new Photo();
$photo->file_name = $fileName;
$photo->save();
}
示例11: imageUpload
public function imageUpload(Request $request)
{
$rules = ['image' => 'required|image|mimes:jpeg'];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect('galerija')->withErrors($validator);
} else {
$name1 = str_random(6) . '.jpg';
$request->file('image')->move('images/web/', $name1);
$photo = new Photo();
$photo->name = 'images/web/' . $name1;
$photo->save();
return redirect('galerija');
}
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$file = $request->file('file');
//Name
$originalName = str_replace(' ', '', $file->getClientOriginalName());
$originalName = str_replace('#', '_', $originalName);
$filename = time() . $originalName;
$image_size = $this->savePhoto($file, $filename);
//make Database entries
$photo = new Photo();
$photo->filename = $filename;
$photo->image_size = $image_size;
$photo->album_id = $request->_id;
$photo->user_id = \Auth::user()->id;
$photo->save();
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store($id, Request $request)
{
foreach ($request->file('images') as $p) {
$photo = new Photo();
$photo->album_id = $id;
$fileName = "";
if ($p->isValid()) {
$path = public_path() . '/uploads/photos/';
$fileName = str_random(32) . '.' . $p->getClientOriginalExtension();
$p->move($path, $fileName);
} else {
App::abort(404);
}
$photo->photo = $fileName;
$photo->save();
}
return Redirect::route('admin.photos.show', $id);
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(PhotoRequest $request)
{
$photo = new Photo($request->except('image'));
$photo->user_id = Auth::id();
$picture = "";
if ($request->hasFile('image')) {
$file = $request->file('image');
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$picture = sha1($filename . time()) . '.' . $extension;
}
$photo->filename = $picture;
$photo->save();
if ($request->hasFile('image')) {
$photoalbum = PhotoAlbum::find($request->photo_album_id);
$destinationPath = public_path() . '/appfiles/photoalbum/' . $photoalbum->folder_id . '/';
$request->file('image')->move($destinationPath, $picture);
}
}
示例15: upload
public function upload($photo, $user_id, $album_id)
{
try {
if (!Storage::disk('local')->exists($user_id)) {
Storage::makeDirectory($user_id);
}
$destinationPath = public_path() . '/uploads/' . $user_id;
$filename = str_random(10) . $photo->getClientOriginalName();
$upload_success = $photo->move($destinationPath, $filename);
if ($upload_success) {
$photo = new Photo();
$photo->name = $filename;
$photo->user_id = $user_id;
$photo->save();
$photo->albums()->attach($album_id);
return array('status' => 1, 'photo' => $photo);
}
} catch (Exception $exp) {
return array('status' => 0);
}
}