本文整理汇总了PHP中app\Image::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::create方法的具体用法?PHP Image::create怎么用?PHP Image::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Image
的用法示例。
在下文中一共展示了Image::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$this->validate($request, ['original_name' => 'required', 'filename' => 'required']);
Image::create($request->all());
Session::flash('flash_message', 'Image added!');
return redirect('admin/image');
}
示例2: postVote
public function postVote(Request $request)
{
if (!Auth::id()) {
return response()->json(['message' => 'user not found'], 400);
}
$profile = Profile::where("id", "=", $request->input("profileId"))->first();
if (!$profile || $profile->isActive != 1) {
return response()->json(['message' => 'profile not found'], 400);
}
$image_file = $request->file('image');
if (!$image_file) {
return response()->json(['message' => 'resource not found'], 400);
}
$image = Image::create();
$image_file->move(storage_path(), md5($image->id));
$img = ImageIntervention::make(storage_path() . '/' . md5($image->id));
$img->resize(1000, 1000, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
$img->save(base_path() . '/public/images/votes/' . md5($image->id) . '.jpg', 100);
$img = ImageIntervention::make(storage_path() . '/' . md5($image->id));
$img->fit(80, 80);
$img->save(base_path() . '/public/images/votes/thumb_80_' . md5($image->id) . '.jpg', 100);
$img = ImageIntervention::make(storage_path() . '/' . md5($image->id));
$img->fit(132, 99);
$img->save(base_path() . '/public/images/votes/thumb_132_' . md5($image->id) . '.jpg', 100);
$vote = Vote::firstOrCreate(['user_id' => Auth::id(), 'profile_id' => $request->input("profileId")]);
$vote->user_id = Auth::id();
$vote->profile_id = $request->input("profileId");
$vote->photo = md5($image->id);
$vote->save();
//$request->session()->push('uploaded_images', $image->id);
return response()->json(['message' => 'created', 'path' => '/images/votes/thumb_80_' . md5($image->id) . '.jpg', 'imageId' => $request->input("imageId")], 201);
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(ImageRequest $request)
{
//
$input = $request->all();
Image::create($input);
return redirect('imagenes');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(CreateImageRequest $request)
{
if ($request->hasFile('imageFile')) {
$path = public_path() . '/uploads/images';
$file = $request->file('imageFile');
$fileName = time() . '_' . $file->getClientOriginalName();
$file->move($path, $fileName);
$image = $fileName;
}
$image = Image::create(['project_id' => $request->input('project_id'), 'filename' => $image]);
if ($image) {
$filename = pathinfo($image->filename, PATHINFO_FILENAME);
$fileExt = pathinfo($image->filename, PATHINFO_EXTENSION);
// Resize image
$img640 = Resizer::make('uploads/images/' . $image->filename)->widen(640);
$img1280 = Resizer::make('uploads/images/' . $image->filename)->widen(1280);
$img1920 = Resizer::make('uploads/images/' . $image->filename)->widen(1920);
$img2560 = Resizer::make('uploads/images/' . $image->filename)->widen(2560);
// Save images
$img640->save('uploads/images/' . $filename . '_640.' . $fileExt);
$img1280->save('uploads/images/' . $filename . '_1280.' . $fileExt);
$img1920->save('uploads/images/' . $filename . '_1920.' . $fileExt);
$img2560->save('uploads/images/' . $filename . '_2560.' . $fileExt);
flash()->success('Image uploaded successfully!');
} else {
flash()->error('Oops! Something went wrong.');
}
return redirect(route('backend'));
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$user_id = Auth::User()->id;
if (Input::file()) {
$file_image = array('image' => Input::file('file_image'));
$rules = array('image' => 'required');
$validator = validator::make($file_image, $rules);
if ($validator->fails()) {
return redirect::to('photo')->withInput()->withErrors($validator);
} else {
if (Input::file('file_image')->isValid()) {
$path = '../public/images';
$extension = Input::file('file_image')->getClientOriginalExtension();
$fileName = rand() . '.' . $extension;
Input::file('file_image')->move($path, $fileName);
Image::create(array('user_id' => $user_id, 'path' => $fileName));
Session::flash('success', 'Upload successfully');
return Redirect::to('photo');
} else {
Session::flash('error', 'uploaded file is not valid');
return Redirect::to('photo');
}
}
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(UploadImageRequest $request, $user)
{
if (!file_exists(public_path() . '/upload')) {
mkdir(public_path() . '/upload');
}
if (!file_exists(public_path() . '/upload/images/')) {
mkdir(public_path() . '/upload/images');
}
$id = Auth::user()->id;
$auth = substr(md5(Auth::user()->id . Auth::user()->email), 0, 10);
$resource = $request->except(['_token', 'image']);
//dd($request->file('image'));
if (!$request->get('album_id')) {
$data_album = ['album_name' => 'Untitled', 'album_title' => 'Untitled album', 'user_id' => $id];
if (!($album = Album::create($data_album))) {
return redirect()->route('photo.create', $user)->withErrors('Unexpected error!');
}
$resource['album_id'] = $album->id;
}
if ($request->hasFile('image')) {
$file = $request->file('image');
$imageName = date('d-m-Y_h-i-s') . '_' . $id . '_' . $file->getClientOriginalName();
$path = $this->path . '/' . $id . '_' . $auth;
$destination = $path;
$folder = public_path() . '/' . $path;
if (!file_exists($folder)) {
mkdir($folder);
}
$image = ['image_name' => $imageName, 'image_size' => $file->getSize(), 'user_id' => $id, 'fullsize_url' => $path . '/' . $imageName];
if ($file->move($destination, $imageName) && Image::create(array_merge($resource, $image))) {
return response()->json(['message' => 'Your photo has been upload!']);
}
}
return response()->json(['message' => 'Unexpected errors']);
}
示例7: add_image
public function add_image(Request $request)
{
$user = Auth::user();
$image_url = trim($request->input('image_url'));
if ($image_url !== '') {
\App\Image::create(['profile_id' => $user->profile->id, 'photo_url' => $image_url]);
}
return redirect('/profile');
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(ImageRequest $request)
{
//
//dd($request->all());
$input = $request->all();
Image::create($input);
Session::flash('flash_message', 'Image successfully added!');
return redirect()->back();
}
示例9: ajaxUploadImage
public function ajaxUploadImage(Request $request)
{
//-- move image to resource folder --
$imgPathArr = $this->moveImage($request->file('uploadImg'), 'article_image');
//-- write record into images table --
Image::create(['path' => $imgPathArr['imgPathname'], 'user' => auth()->user()->id]);
//-- return response --
return response()->json(['imgSrc' => $imgPathArr['imgUrl']]);
}
示例10: uploadBanner
public function uploadBanner(Request $request)
{
$imagefile = $request->file('file');
$imageFileName = time() . '.' . $imagefile->getClientOriginalExtension();
$s3 = Storage::disk('s3');
$filePath = 'banners/' . $imageFileName;
$s3->put($filePath, file_get_contents($imagefile), 'public');
$url = $s3->getAdapter()->getClient()->getObjectUrl('passioncouragefun', $filePath);
$image = Image::create(['name' => $imagefile->getClientOriginalName(), 'url' => $url, 'type' => 'banner']);
return ['id' => $image->id, 'name' => $imageFileName];
}
示例11: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$image = Image::create(Input::all());
$image->name = Input::all()['name'];
$image->user_id = Auth::id();
$image->description = Input::all()['description'];
$image->save();
#return view("image/show",['img'=>$image]);
return Redirect::to('/home');
}
示例12: uploadImagesToS3
public function uploadImagesToS3(Request $request)
{
$imagefile = $request->file('file');
$name = $imagefile->getClientOriginalName();
$ext = $imagefile->getClientOriginalExtension();
$modifiedname = substr($name, 0, strrpos($name, $ext) - 1);
$imageFileName = time() . '.' . $ext;
$s3 = Storage::disk('s3');
$s3->put($imageFileName, file_get_contents($imagefile), 'public');
$url = $s3->getAdapter()->getClient()->getObjectUrl('megadealsg', $imageFileName);
Image::create(['name' => $modifiedname, 'url' => $url]);
return 1;
}
示例13: save
/**
* Save a file to the database.
*
* @param File $file
* @return string
*/
public function save(File $file)
{
$image = file_get_contents($file);
$hash = sha1($image);
$model = Image::where('hash', $hash)->first();
if (!$model) {
$model = Image::create(['hash' => $hash, 'image' => $image]);
}
unset($image);
unset($file);
if ($model) {
return $this->url($model->id);
}
}
示例14: store
/**
* Store a newly created Cruiseline.
*
* @param Request $request
* @param Cruiseline $brand
* @return mixed
*/
public function store(CreateImage $request)
{
$image = Image::create($request->all());
if ($request->hasFile('image')) {
if ($request->file('image')->isValid()) {
$upload = $request->file('image');
$moveUpload = $upload->move(public_path() . '/uploads', $filename = time() . '-' . $upload->getClientOriginalName());
$image->file = $filename;
} else {
return redirect()->back()->withInput();
}
}
$image->save();
return redirect('home/galleries');
}
示例15: getPropertyImages
public function getPropertyImages($MLSNumber)
{
do {
// TODO: this may be where the timeout is occuring
$photos = \App\Libraries\RetsQuery::photos('Property', 'LargePhoto', $MLSNumber);
} while ($photos[0]->getContentId() == null);
foreach (array_slice($photos->toArray(), 0, 10) as $photo) {
$imageDiffer = str_random(40);
$localDiskImage = '/tmp' . '/property-' . $MLSNumber . '-image-' . $imageDiffer . '.jpg';
file_put_contents($localDiskImage, (string) $photo->getContent());
$s3File = dispatch((new UploadImagesToS3($MLSNumber, $imageDiffer . '.jpg', $localDiskImage))->onQueue('s3Upload'));
$createImage = \App\Image::create(['dataUri' => 'https://s3.sapioweb.com/jacobsgroupvegas/properties/' . env('APP_ENV') . '/' . $MLSNumber . '/' . $imageDiffer . '.jpg']);
$images[] = $createImage->id;
}
return $images;
}