Skip to content
Snippets Groups Projects
Commit 1ba6a147 authored by gop20's avatar gop20
Browse files

corrigido bug na ordem das imagens na galeria

parent 29f0ceba
No related branches found
No related tags found
No related merge requests found
Showing
with 112 additions and 15 deletions
images/usr_avatar.png

17.8 KiB

APP_NAME=Laravel
APP_NAME="Remember PET"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
......
......@@ -16,12 +16,12 @@ class GalleryController extends Controller
{
$search = request()->query('search');
if($search){ // testa se ha um request de search
$images = Image::where('title', 'LIKE', '%' . $search . '%')->orderBy('title')->paginate(10);
$images = Image::where('title', 'LIKE', '%' . $search . '%')->orderBy('year', 'desc')->paginate(4);
}
else{
$images = Image::paginate(10);
$images = Image::orderBy('year', 'desc')->paginate(4);
}
$imageYears = ImageYears::orderBy('year')->get();
$imageYears = ImageYears::orderBy('year', 'desc')->get();
return view('dashboard.galeria.index')->with(['images' => $images, 'imageYears' => $imageYears, 'search' => $search]);
}
......
......@@ -51,12 +51,12 @@ class HomeController extends Controller
{
$search = request()->query('search');
if($search){ // testa se ha um request de search
$images = Image::where('title', 'LIKE', '%' . $search . '%')->orderBy('title')->paginate(10);
$images = Image::where('title', 'LIKE', '%' . $search . '%')->orderBy('year', 'desc')->paginate(4);
}
else{
$images = Image::orderBy('title')->paginate(10);
$images = Image::orderBy('year', 'desc')->paginate(4);
}
$imageYears = ImageYears::orderBy('year')->get();
$imageYears = ImageYears::orderBy('year', 'desc')->get();
return view('frontend.gallery.index')->with(['images' => $images, 'imageYears' => $imageYears, 'frase' => $this->frase(), 'search' => $search]);
}
......
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ImageYears extends Model
{
protected $primaryKey = 'id';
protected $fillable = [
'year'
];
public function images()
{
return $this->hasMany(Image::class, 'year');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateImageYearsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('image_years', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('year');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('image_years');
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateImagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('description');
$table->string('path');
$table->unsignedInteger('year');
$table->timestamps();
$table->foreign('year')->references('year')->on('image_years')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('images');
}
}
......@@ -243,3 +243,13 @@ textarea {
padding-top:30px;
padding-bottom: 30px;
}
.int_img_max_i{
max-height: 350px !important;
max-width: 650px !important;
}
.int_img_max_s{
max-height: 600px !important;
max-width: 1000px !important;
}
......@@ -30,8 +30,8 @@
<div class="card-box">
<h4 class="m-t-0 m-b-10 header-title" align="center">{{ $interview->name }}</h4>
<div class="text-center" style="margin-bottom: 15px">
<img class="img-fluid rounded mb-5 mb-md-0" src="{{ asset('storage/images/entrevistas/' . $interview->image_path) }}"
height="500" width="auto" alt="{{ $interview->name }}">
<img class="img-fluid rounded mb-5 mb-md-0" style="max-width: 1000px" src="{{ asset('storage/images/entrevistas/' . $interview->image_path) }}"
height="500px" width="auto" alt="{{ $interview->name }}">
</div>
<p class="m-b-40">{{ $interview->sumary }}</p>
<p class="m-b-30">{!! $interview->content !!}</p>
......
......@@ -22,12 +22,12 @@
</div>
@forelse($interviews as $interview)
<!-- Project One -->
<!-- entrevista -->
<div class="row">
<div class="col-md-7 text-center">
<a href="#">
<img class="img-fluid rounded mb-3 mb-md-0" src="{{ asset('storage/images/entrevistas/' . $interview->image_path) }}"
height="300" width="auto" alt="{{ $interview->name }}">
<img class="img-fluid rounded mb-3 mb-md-0 int_img_max_i" src="{{ asset('storage/images/entrevistas/' . $interview->image_path) }}"
height="350px" width="auto" alt="{{ $interview->name }}">
</a>
</div>
<div class="col-md-5">
......
......@@ -6,12 +6,12 @@
<section class="gallery-block cards-gallery">
<div class="container">
<div class="heading">
<div class="heading text-center">
<h1 class="text-uppercase">{{ $interview->name }}</h1>
</div>
<div class="text-center" style="margin-bottom: 15px">
<img class="img-fluid rounded mb-5 mb-md-0" src="{{ asset('storage/images/entrevistas/' . $interview->image_path) }}"
height="700" width="auto" alt="{{ $interview->name }}">
<img class="img-fluid rounded mb-5 mb-md-0 int_img_max_s" src="{{ asset('storage/images/entrevistas/' . $interview->image_path) }}"
height="600px" width="auto" alt="{{ $interview->name }}">
</div>
<div class="text-center" style="font-size: 23px; margin-bottom: 50px">
{{ $interview->sumary }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment