Laravel - FatalErrorException in usahaController.php line 33: Call to a member function paginate() on a non-object - laravel-5.1

I am making a search page in Laravel and cant understand how to use the paginate method for this usage.
I have used it else where, but not like this.
usahaController
public function feindex() {
$hasil= DB::select('sELECT anggota.USERNAME, kategori_usaha.NAMA_KATEGORI_USAHA, usaha.NAMA_USAHA,
usaha.TYPE_UMKM, usaha.GAMBAR_UMUM, usaha.ALAMAT_USAHA, usaha.NOMOR_TLPN_USAHA FROM usaha
JOIN anggota on usaha.ID_ANGGOTA=anggota.ID_ANGGOTA
JOIN kategori_usaha on usaha.ID_KATEGORI_USAHA=kategori_usaha.ID_KATEGORI_USAHA')->paginate(2);
$keranjang['usaha']=$hasil;
return view('feindex', $keranjang);
}
view
#foreach ($usaha as $item)
<div class="col-sm-6 col-md-3">
<div class="thumbnail text-center">
<a href="single_product.html">
<img src="{{ asset('uploads/'.$item->GAMBAR_UMUM) }}" class="img-responsive">
</a>
<br/>
<h5 class="text-primary">{{$item->NAMA_USAHA}}</h5>
<ul>
<li><i class="livicon" data-name="check" data-size="18"
data-loop="true" data-c="#787878" data-hc="787878"></i> Nama Pengusaha :<br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp{{$item->USERNAME}}</li>
<li><i class="livicon" data-name="check" data-size="18"
data-loop="true" data-c="#787878" data-hc="787878"></i> {{$item->NAMA_KATEGORI_USAHA}}</li>
<li><i class="livicon" data-name="check" data-size="18"
data-loop="true" data-c="#787878" data-hc="787878"></i> {{$item->ALAMAT_USAHA}} </li>
<li><i class="livicon" data-name="check" data-size="18"
data-loop="true" data-c="#787878" data-hc="787878"></i> {{$item->NOMOR_TLPN_USAHA}}</li>
<li><i class="livicon" data-name="check" data-size="18"
data-loop="true" data-c="#787878" data-hc="787878"></i> {{$item->TYPE_UMKM}} </li>
</ul>
View
</div>
</div>
#endforeach
{!! $usaha->render() !!}
how fix this

public function feindex() {
$hasil= DB::select('SELECT anggota.USERNAME, kategori_usaha.NAMA_KATEGORI_USAHA, usaha.NAMA_USAHA,
usaha.TYPE_UMKM, usaha.GAMBAR_UMUM, usaha.ALAMAT_USAHA, usaha.NOMOR_TLPN_USAHA FROM usaha')
->join('anggota', 'usaha.ID_ANGGOTA','=','anggota.ID_ANGGOTA')
->join('kategori_usaha','usaha.ID_KATEGORI_USAHA','=','kategori_usaha.ID_KATEGORI_USAHA')
->paginate(2);
$keranjang=$hasil;
return view('usaha', $keranjang);
}

Related

Bootstrap 5 & Rails: header menu with left center right content, weird behaviour

I'm working on a simple header for my Bootstrap 5 project.
Idea is to have Logo at the left, menu in the center and login/logout at the right.
This is the code:
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand ms-auto" href="http://www.foodissey.it">Foodissey</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<div class="navbar-nav mx-auto">
<%= link_to "Home", static_pages_home_path, class: "nav-link " %>
<%= link_to "Il Progetto", static_pages_project_path, class: "nav-link " %>
<%= link_to "Chi Siamo", static_pages_team_path, class: "nav-link " %>
<%= link_to "Blog", static_pages_blog_path, class: "nav-link " %>
<%= link_to "Shop", static_pages_shop_path, class: "nav-link " %>
<%= link_to "Regalistica Aziendale", static_pages_b2b_path, class: "nav-link " %>
</div>
<div class="navbar-nav me-auto">
<%= link_to "Login", '#', class: "nav-link " %>
</div>
</div>
</div>
</nav>
The result is that the "Login" is not at the end-right of the navbar, but it is somewhere in the middle-right, and I don't understand why.
Edit: this is similar code without erb references, tried on codeply and I have same behaviour:
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand ms-auto" href="http://www.foodissey.it">Foodissey</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<div class="nav navbar-nav mx-auto">
<a href="#" class="nav-link " %> Uno </a>
<a href="#" class="nav-link " %> due </a>
<a href="#" class="nav-link " %> tre </a>
<a href="#" class="nav-link " %> quattro </a>
</div>
<div class="nav navbar-nav me-auto">
<a href="#" class="nav-link " %> login </a>
</div>
</div>
</div>
</nav>
Your markup is slightly off for bootstrap 5:
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand d-flex w-50 me-auto" href="http://www.foodissey.it">Foodissey</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse w-100" id="navbarSupportedContent">
<div class="nav navbar-nav w-100 justify-content-center">
<a href="#" class="nav-link " %> Uno </a>
<a href="#" class="nav-link " %> due </a>
<a href="#" class="nav-link " %> tre </a>
<a href="#" class="nav-link " %> quattro </a>
</div>
<div class="nav navbar-nav ms-auto w-100 justify-content-end">
<a href="#" class="nav-link " %> login </a>
</div>
</div>
</div>
</nav>
With the corresponding codepen: https://codepen.io/james00794/pen/KKWvdoV.
Note the justify-content-* classes - these are key to position things when using flex layouts in bootstrap 5.

Kendo toolbar misbehave

I'm having a problem implementing a toolbar for kendo grid. The problem is a partial view used to load a left-sided menu for a specific module in the website application.
So far, I have not been able to work around this, thus I'm asking here for help.
This is what the grid looks like without the left menu:
This is what the grid looks like with the left menu:
So far, this is what the menu code has:
<nav class="navbar navbar-default navbar-left" style="margin:0px; padding:0px; border-color:lightgray;">
<div class="collapse navbar-collapse" style="margin:0px; padding:0px;">
<ul class="nav navbar-">
#if (Request.IsAuthenticated)
{
<li>
<a href="#Url.Action("Index", "FicheiroIdqa")">
<span class="fa fa-circle" style="font-size:8px; vertical-align:middle;"></span> Ficheiros Idqa
</a>
</li>
<li>
<a href="#Url.Action("Index", "ZaPe")">
<span class="fa fa-circle" style="font-size:8px; vertical-align:middle;"></span> ZaPes
</a>
</li>
<li>
<a href="#Url.Action("Index", "LocalColheita")">
<span class="fa fa-circle" style="font-size:8px; vertical-align:middle;"></span> Locais Colheita
</a>
</li>
<li>
<a href="#Url.Action("Index", "FamiliaParametro")">
<span class="fa fa-circle" style="font-size:8px; vertical-align:middle;"></span> Famílias Parâmetro
</a>
</li>
<li>
<a href="#Url.Action("", "")">
<span class="fa fa-circle" style="font-size:8px; vertical-align:middle;"></span> Editais
</a>
</li>
<li>
<a href="#Url.Action("Index", "Resultados")">
<span class="fa fa-circle" style="font-size:8px; vertical-align:middle;"></span> Export. Resultados
</a>
</li>
}
</ul>
</div>
And this is the code in the view, where I am calling the partial with the menu:
#model List<INL.InLabLimsAqua.OnlineResults.WebApp.ViewModels.FicheiroIdqaViewModel>
#{ ViewBag.Title = "Ficheiros Idqa"; }
<h5>#Html.ActionLink("Ersar", "Index", "Ersar") > #ViewBag.Title</h5>
<hr />
<div class="col-md-2" style="padding-left:0px; width:200px;">
#Html.Partial("~/Views/Ersar/_ErsarMenu.cshtml")
</div>
<div class="col-md-offset-1" style="padding-left:95px;">
...
grid configuration
...
</div>
I think the problem resides in the fact that the toolbar is being loaded in the same row as the left menu, and it pushes it down with its height.
Any help to fix this would be much appreciated.

List showing the last 3 items

I use this code for my slider in my view
but I want to show the last 3 items
<div class="flexslider">
<ul class="slides">
#foreach (var item in ViewBag.blog)
{
<li>
<a href="#">
<img src="#item.postImage" width="100%" alt="PostImage" style="margin-bottom: 10px;" />
<p class="flex-caption">#item.postTitle</p>
</a>
</li>
}
</ul>
</div>
<div class="flexslider">
<ul class="slides">
#foreach (var item in ((List<your Model>)ViewBag.blog).Skip(((List<your Model>)ViewBag.list).Count-3))
{
<li>
<a href="#">
<img src="#item.postImage" width="100%" alt="PostImage" style="margin-bottom: 10px;" />
<p class="flex-caption">#item.postTitle</p>
</a>
</li>
}
</ul>
</div>

Validation in dropdown goes wrong in ASP.Net mvc

I have a login page, but whenever I typed wrong credentials it showing the mainheader for login person but with no name.. See the image I attached for further explanations
login
login with wrrong credentials
this is what it look like when the person login successfully, it have name and company
View form
<ul class="nav navbar-nav navbar-right">
#{
AccountContactVM customer = (AccountContactVM)ViewBag.AccountData;
}
#if (customer.User == customer.User && customer.User != null )
{
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<i class="fa fa-user-circle fa-fw fa-lg" aria-hidden="true"</i>
#customer.User.FirstName #customer.User.LastName
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li class="disabled">
<div class="row">
<div class="col-md-3">
<i class="fa fa-user-circle" style="font-size:40px;padding:5px 20px;" aria-hidden="true"></i>
</div>
<div class="col-md-9">
<p style="padding-top:5px;">
#customer.User.FirstName #customer.User.LastName
<br />
#customer.Company.AccountName
</p>
</div>
</div>
</li>
<li class="divider"></li>
<li><a asp-controller="Account" asp-action="Index">Customer Portal</a></li>
<li class="divider"></li>
<li><a a asp-controller="Account" asp-action="LogOut">Logout</a></li>
</ul>
</li>
}
else
{
<li><a asp-controller="Account" asp-action="SignUp">Register</a></li>
<li><a asp-controller="Account" asp-action="SignIn"><i class="fa fa-sign-in fa-fw" aria-hidden="true"></i>Login</a></li>
}
<li ng-cloak><span class="glyphicon glyphicon-shopping-cart"></span></i>Cart(<strong>{{CartCount}}</strong>)</li>
</ul>

Custom Helper can't render content of PartialView

The html.Partial doesn't working very well, in fact it shows just path ~/Views/Shared/IconMenuPSA.cshtml, instead of showing the HTML content.
Where am I doing wrong?
My simple custom Helper in App_Code folder:
Helper
#using System.Web.Mvc.Html
#helper DefaultTitle(System.Web.Mvc.HtmlHelper html, string content) {
<br />
<div class="well well-sm text-center text-primary">
html.Partial("~/Views/Shared/IconMenuPSA.cshtml")
<p style="font-size:x-large">#content</p>
</div>
}
View
#model DatiGeneraliViewModel
#{
ViewBag.Title = "DatiGenerali";
Layout = "~/Views/Shared/_LayoutMainPage.cshtml";
}
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/jqueryui")
#Scripts.Render("~/bundles/bootstrap")
#MyHelper.DefaultTitle(Html, "Dati Generali")
PartialView
<div style="float:left">
<!-- Split button -->
<div class="btn-group">
<a href="MainPage" class="btn btn-primary" title="Torna al cruscotto">
<span class="glyphicon glyphicon-tasks"></span>
</a>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li>Cruscotto</li>
<li role="separator" class="divider"></li>
<li>Dati Generali</li>
<li role="separator" class="divider"></li>
<li>Riepilogo </li>
</ul>
</div>
</div>
How do I fix this?
Thanks.

Resources