Permalink
Browse files

Page Builder - add page components when you edit page

  • Loading branch information...
bpocallaghan committed Oct 25, 2017
1 parent 913cd7a commit 00ad3a94b6eeb5978dabb91b35d15bae71838c27
@@ -7,7 +7,6 @@
use App\Http\Requests;
use App\Models\Content;
use App\Models\PageContent;
use App\Models\PageSection;
use Illuminate\Http\Request;
use App\Http\Controllers\Admin\AdminController;
@@ -96,7 +96,7 @@ public function update(Page $page, PageMedia $medium)
*/
private function moveAndCreatePhoto(
UploadedFile $file,
$size = ['l' => [800, 800], 's' => [300, 300]]
$size = ['l' => [1000, 1000], 's' => [300, 300]]
) {
$extension = '.' . $file->extension();
@@ -118,26 +118,24 @@ private function moveAndCreatePhoto(
// if width is the biggest - resize on max width
if ($imageTmp->width() > $imageTmp->height()) {
// resize the image to the large width and constrain aspect ratio (auto height)
$imageTmp->resize($largeSize[0], null, function ($constraint) {
// resize the image to the large height and constrain aspect ratio (auto width)
$imageTmp->resize(null, $largeSize[1], function ($constraint) {
$constraint->aspectRatio();
})->save($path . $filename);
// resize the image to the thumb width and constrain aspect ratio (auto width)
$imageTmp->resize($thumbSize[0], null, function ($constraint) {
// resize the image to the thumb height and constrain aspect ratio (auto width)
$imageTmp->resize(null, $thumbSize[1], function ($constraint) {
$constraint->aspectRatio();
})->save($path . $name . ImageThumb::$thumbAppend . $extension);
}
else {
// resize the image to the large height and constrain aspect ratio (auto width)
$imageTmp->resize(null, $largeSize[1], function ($constraint) {
// resize the image to the large width and constrain aspect ratio (auto height)
$imageTmp->resize($largeSize[0], null, function ($constraint) {
$constraint->aspectRatio();
})->save($path . $filename);
// resize the image to the thumb height and constrain aspect ratio (auto width)
$imageTmp->resize(null, $thumbSize[1], function ($constraint) {
// resize the image to the thumb width and constrain aspect ratio (auto width)
$imageTmp->resize($thumbSize[0], null, function ($constraint) {
$constraint->aspectRatio();
})->save($path . $name . ImageThumb::$thumbAppend . $extension);
}
@@ -22,7 +22,7 @@ public function index(Page $page)
$page->load('sections.component');
return $this->view('pages.components.components')->with('page', $page);
return $this->view('pages.components.page_components')->with('page', $page);
}
/**
@@ -52,9 +52,7 @@ private function showPhotoable($photoable, $photos)
*/
public function showNewsPhotos(News $news)
{
$photos = $news->photos;
return $this->showPhotoable($news, $photos);
return $this->showPhotoable($news, $news->photos);
}
/**
@@ -64,9 +62,7 @@ public function showNewsPhotos(News $news)
*/
public function showAlbumPhotos(PhotoAlbum $album)
{
$photos = $album->photos;
return $this->showPhotoable($album, $photos);
return $this->showPhotoable($album, $album->photos);
}
/**
@@ -76,9 +72,7 @@ public function showAlbumPhotos(PhotoAlbum $album)
*/
public function showArticlePhotos(Article $article)
{
$photos = $article->photos;
return $this->showPhotoable($article, $photos);
return $this->showPhotoable($article, $article->photos);
}
/**
@@ -165,7 +159,7 @@ public function destroy(Photo $photo)
private function moveAndCreatePhoto(
UploadedFile $file,
$photoable,
$size = ['l' => [800, 800], 's' => [200, 200]]
$size = ['l' => [1000, 1000], 's' => [300, 300]]
) {
$extension = '.' . $file->extension();
@@ -197,12 +191,37 @@ private function moveAndCreatePhoto(
// save original
$imageTmp->save($path . $name . Photo::$originalAppend . $extension);
// save large
/*// save large
$imageTmp->fit($largeSize[0], $largeSize[1])->save($path . $filename);
// save thumbnail from the original image
$imageTmp->fit($thumbSize[0], $thumbSize[1])
->save($path . $name . Photo::$thumbAppend . $extension);
->save($path . $name . Photo::$thumbAppend . $extension);*/
// if width is the biggest - resize on max width
if ($imageTmp->width() > $imageTmp->height()) {
// resize the image to the large height and constrain aspect ratio (auto width)
$imageTmp->resize(null, $largeSize[1], function ($constraint) {
$constraint->aspectRatio();
})->save($path . $filename);
// resize the image to the thumb height and constrain aspect ratio (auto width)
$imageTmp->resize(null, $thumbSize[1], function ($constraint) {
$constraint->aspectRatio();
})->save($path . $name . ImageThumb::$thumbAppend . $extension);
}
else {
// resize the image to the large width and constrain aspect ratio (auto height)
$imageTmp->resize($largeSize[0], null, function ($constraint) {
$constraint->aspectRatio();
})->save($path . $filename);
// resize the image to the thumb width and constrain aspect ratio (auto width)
$imageTmp->resize($thumbSize[0], null, function ($constraint) {
$constraint->aspectRatio();
})->save($path . $name . ImageThumb::$thumbAppend . $extension);
}
$originalName = $file->getClientOriginalName();
$originalName = substr($originalName, 0, strpos($originalName, $extension));
@@ -88,7 +88,7 @@ public function components()
*/
public function banners()
{
return $this->belongsToMany(Banner::class)->orderBy('created_at', 'DESC');
return $this->belongsToMany(Banner::class)->active()->orderBy('created_at', 'DESC');
}
/**
Oops, something went wrong.

0 comments on commit 00ad3a9

Please sign in to comment.