I'm laravel newbie. I'm created simple code and I have some questions:
I think this code bad (it works, but I use @forelse($forums as $forum)
and anywhere use $forum)
@extends('layouts.main')
@section('content')
@forelse($forums as $forum) <-- I don't like this line, it works but i think it's possible with if or something else
@forelse($topics as $topic)
{{ $topic->title }}<br>
@empty
Sorry but this forums empty.
@endforelse
@empty
Sorry but this forum not found
@endforelse
@stop
And second question how to make pagination? I'm tried this:
<?php
namespace App\Http\Controllers;
use DB;
use View;
class viewForum extends Controller
{
public function showForum($fname, $fid)
{
return View::make('forum', [
'forums' => DB::table('forums')
->where('id', $fid)
->where('seo_name', $fname)
->select()
->get()
->simplePagination(5)
]);
}
}
But not work's, I'm tried tutorials..etc, how to? Thanks so much in advance ! :)