本文整理汇总了PHP中app\Image类的典型用法代码示例。如果您正苦于以下问题:PHP Image类的具体用法?PHP Image怎么用?PHP Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: composeSideBar
public function composeSideBar()
{
view()->composer('sections.right_bar', function ($view) {
$sideBarImages = new Image();
$view->with('sideBarImages', $sideBarImages->getSideBarImages());
});
}
示例2: store
/**
* Store a newly uploaded resource in storage.
*
* @return Response
*/
public function store(ImageRequest $request)
{
$input = $request->all();
if (Auth::user()->image != null) {
$image = Auth::user()->image;
$file = Input::file('image');
$name = time() . '-' . $file->getClientOriginalName();
$image->filePath = $name;
$file->move(public_path() . '/images/', $name);
} else {
// Store records process
$image = new Image();
$this->validate($request, ['title' => 'required', 'image' => 'required']);
$image->title = $request->title;
$image->description = $request->description;
$image->user_id = Auth::user()->id;
if ($request->hasFile('image')) {
$file = Input::file('image');
$name = time() . '-' . $file->getClientOriginalName();
$image->filePath = $name;
$file->move(public_path() . '/images/', $name);
}
}
$image->save();
$user = Auth::user();
return redirect('/' . $user->username);
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function store(Request $request)
{
try {
if (!$request->hasFile('photo')) {
return $this->respondWithError('No photo is selected');
}
$file = $request->file('photo');
// Create Eloquent object
$image = new Image();
$image->point_id = $request->id;
$image->filename = $this->generate_random_string();
$image->mime_type = $file->getClientMimeType();
$image->base_64 = $this->convert_to_base_64($file);
$image->created_by = Auth::user()->id;
$image->updated_by = Auth::user()->id;
if (!$image->save()) {
// If creation fails
// Return error response
return $this->respondInternalError();
}
// Select latest row from DB
$resp = $image->orderBy('id', 'DESC')->first();
// return with Fractal
return Fractal::item($resp, new \App\Transformers\ImageTransformer())->responseJson(200);
} catch (Exception $e) {
return $this->respondInternalError();
}
}
示例4: makeImage
protected function makeImage($file, $height, $width, $randomFilename, $thumbnail = null)
{
$md5 = md5_file($file->getRealPath());
$img = Image::make($file)->fit($height, $width);
$path = 'images/';
if ($thumbnail != null) {
$path = 'images/thumb/';
}
$image = Images::where('md5_hash', $md5)->first();
if ($image === null or $image->thumbnail_file == null) {
Clockwork::info('Storing on Filesystem');
$img->save(storage_path() . '/app/' . $path . $randomFilename . '.png', 90);
}
if ($image === null and $thumbnail === null) {
Clockwork::info('New Image');
$image = new Images();
$image->user_id = Auth::user()->id;
$image->filename = $file->getClientOriginalName();
$image->file = $randomFilename . '.png';
$image->height = $height;
$image->width = $width;
$image->md5_hash = $md5;
} elseif ($thumbnail != null and $image->thumbnail_file == null) {
Clockwork::info('Thumbnail Updated');
$image->thumbnail_file = $randomFilename . '.png';
}
$image->save();
return $image;
}
示例5: storeImage
public function storeImage($userID, $imageName, $imagePath)
{
$storeImg = new Image();
$storeImg->userID = $userID;
$storeImg->imageName = $imageName;
$storeImg->imagePath = $imagePath;
$storeImg->save();
}
示例6: saveImagable
public function saveImagable()
{
$imageable = new Image();
$imageable->path = $this->getPathWithFile();
$imageable->imageable_id = $this->model_id;
$imageable->imageable_type = $this->model_class_path;
$imageable->r_id = $this->r_id;
$imageable->save();
return $imageable;
}
示例7: newPicture
public function newPicture($fileName, $image)
{
$path = public_path('/images/gallery/');
File::exists($path) or File::makeDirectory($path, 0755, true);
$image->resize(200, 200)->save($path . $fileName);
$picture = new Image();
$picture->user = Auth::user()->name;
$picture->caption = Input::get('caption');
$picture->imagePath = 'images/gallery/' . $fileName;
$picture->save();
}
示例8: saveAjax
public function saveAjax(Request $request)
{
$filename = $request->get('name') . '-' . uniqid() . '.' . $request->get('format');
$data = $request->get('data');
$data = file_get_contents($data);
file_put_contents(public_path() . '/media/tmp/' . $filename, $data);
$image = new Image();
$image->name = $request->get('name');
$image->user_id = \Auth::user()->id;
$image->save();
$image->addMedia(public_path() . '/media/tmp/' . $filename)->toMediaLibrary();
}
示例9: save
public function save(Request $request)
{
$data = Input::get('image');
list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data);
$data = base64_decode($data);
$now = Carbon::now()->toDateTimeString();
$random = strval(rand());
$path = 'uploads/' . $now . '_' . $random . '.png';
file_put_contents($path, $data);
$image = new Image();
$image->path = $path;
$image->likes = 0;
$image->save();
}
示例10: compose
public function compose(View $view)
{
$tags = Tag::orderBy('id', 'DESC')->get();
$categories = Category::orderBy('id', 'DESC')->simplepaginate(7);
$images = Image::orderBy('id', 'DESC')->paginate(4);
$view->with('tags', $tags)->with('categories', $categories)->with('images', $images);
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//Truncate
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
User::truncate();
Admin::truncate();
Customer::truncate();
Address::truncate();
Category::truncate();
Product::truncate();
Brand::truncate();
Type::truncate();
Image::truncate();
DB::statement('TRUNCATE category_product;');
Product::clearIndices();
Product::reindex();
//Unguard
Model::unguard();
//Call
$this->call(UsersTableSeeder::class);
$this->call(ProductsTableSeeder::class);
//Reguard
Model::reguard();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
示例12: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($type, $id)
{
if ($id == 'video') {
$events = Video::all();
return view('video.show', compact('events'));
} elseif ($id == 'staff') {
$events = Staff::all();
return view('staff.show', compact('events'));
} elseif ($id == 'gallery') {
$events = Image::all();
return view('gallery.show', compact('events'));
} else {
$event = Event::where('slug', $id)->where('type', $type)->first();
$location = Location::where('event_id', $event->id)->first();
$slider = EventImage::where('event_id', $event->id)->orderBy(\DB::raw('RAND()'))->take(4)->get();
$gallery = EventImage::where('event_id', $event->id)->first();
if ($event->type == $type) {
if ($event->status == 1) {
return view($type . '.show', compact('event', 'location', 'slider', 'gallery'));
} else {
return redirect('/' . $type . '/');
}
}
}
}
示例13: 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');
}
}
}
}
示例14: save
/**
* Save product to database
*/
public function save()
{
$data = ['item_id' => $this->item_id, 'shop_id' => $this->shop_id] + $this->data;
if (!App\Product::where('shop_id', $this->shop_id)->where('item_id', $this->item_id)->update($this->data) && !App\Product::insert($data)) {
return false;
}
$this->id = App\Product::where('shop_id', $this->shop_id)->where('item_id', $this->item_id)->first()->id;
if (!$this->id) {
return false;
}
foreach ($this->images as $image) {
if (!App\Image::where('url', $image['url'])->update($image) && !App\Image::insert($image + ['product_id' => $this->id])) {
return false;
}
}
/*if( isset( $this->params ) )
{
foreach( $this->params as $param )
{
if( !App\Param::where( 'param', $param['param'] )->update( $param ) &&
!App\Param::insert( $param + [ 'product_id' => $this->id ] ) )
return false;
}
}*/
return true;
}
示例15: aboutUs
/**
* Fungsi buat tampilan about us
*/
public function aboutUs()
{
$about = About::first();
$gallery = Image::all();
$tipe = Type::all();
return view('FrontEnd.aboutUs', compact('about', 'gallery', 'tipe'));
}