Method render does not exist - laravel-5

I am trying to render my view but i got error
its says Method render does not exist . (View:
my view is
#foreach($forumindex->forumindex()->paginate(2) as $comment)
<p><div class="well">{{ $comment->comment }}</div></p>
#endforeach
{!! $forumindex->forumindex->render() !!}
when i remove {!! $forumindex->forumindex->render() !!} its working fine and i see only 2 post
help me i don't know what code is right

The render() method to build the paginator view has been renamed to links() on Laravel 5.2.
Source: https://laravel.com/docs/5.2/pagination

Related

Undefined Slot variable in Laravel

I am getting an error which is "Undefined variable: nav"
In my home.blade.php,I have this code
#extends('master')
#section('content')
{!! $nav !!}
#endsection
And in my header component(header.blade.php)
#component('component.header')
#slot('nav')
new html
#endslot
#endcomponent
Can you help?
FYI my component is in a component directory in views and home is in views directory

Errors using alaouy/Youtube package with Laravel 5.4 for fetching videos from Youtube

I am using alaouy/Youtube package on Laravel 5.4. It's fetching videos from Youtube but I am getting errors.
// view
#extends('welcome')
#section('content')
<ul>
#foreach($videos as $data)
<div class="well">
{{ $data->id->videoId}}
</div>
#endforeach
</ul>
#endsection
// controller
$videos = Youtube::search($search);
return view('search',compact('videos'));
I am able to get access to all the data in the object except {{$data->id->videoId}}
// Error
Undefined property: stdClass::$videoId (View:
C:\Users\derrick\testyoutubeapi\resources\views\search.blade.php)
You are not receiving the required data so you are getting the error message of not defined property.
in other words, you are requesting videoId field which is not there for some of kinds like playlist (playlistId), or maybe a channel (channelId)
so your problem solution should be just making your code in the view to check if there is a field that is called videoId or no before the query:
#foreach($videos as $data)
#if(isset($data->id->videoId)) // field available?
<div class="well">
{{ $data->id->videoId}}
#endif // end if
</div>
#endforeach

Laravel 5.4 method not allow on patch

I'm working on updating the data through a PATCH form, the form is working on localhost, but it is not working on server, i have check the route list the route i create is using the PATCH method also, but laravel return me a method not allow exception, here is my code:
Controller:
public function registercert (Request $request, $id) {
// return $request->all();
$user = User::findOrFail($id);
}
Route:
Route::patch('admin/user/registercert/{id}', ['as'=>'registercert', 'uses'=>'admin\AdminUserController#registercert']);
View:
{!! Form::open(['method'=>'PATCH', 'action'=>['admin\AdminUserController#registercert',$user_id], 'enctype'=>'multipart/form-data']) !!}
{!! csrf_field() !!}
...
{!! Form::close() !!}
I had a similar problem, I fixed it using a "regular" form with a POST method and adding laravel's method spoofing
<form class="form" action="/clientes/{{ $cliente->id }}" method="POST" enctype="multipart/form-data" >
{{ method_field('PUT') }}
#include('partial.cliente-campos')
</form>
The important part here is the method="POST" in the form and the {{ method_field('PUT') }}. You need both.

Laravel white page loading route

I had a login.blade.php with some code, and I decided to replace with a new one.
I renamed it to old_login.blade.php and create a new file, in the same path, with the name login.blade.php.
After a while, I decided to rollback to my old login page.
I delete login.blade.php, and renamed the old_login.blad.php with the original name to return back.
No code was edited, only views.
The problem is that the page returned a blanck white page with many comments (the comment's tag is not closed).
I try to make a copy of the view, called test.blade.php, and change the route to that view. It diplay them correctly. But If I change another time route to myapp.login to display login.blade.php view, it won't work.
I try anything but nothing is changed. I'm using laravel 5.1.
The code insiede my routes.php is
Route::get('/', function () {
return view('myapp.login');
});
the code inside the login.blade.php (same ad test.blade.php) is:
#extends("app")
#section("content")
{!! Form::open(["url" => "home"]) !!}
<div class="form-group">
{!!Form::label("username", "Username:") !!}
{!!Form::text("usr_username", "Luca", ["class" => "form-control"]) !!}
</div>
<div class="form-group">
{!!Form::label("password", "Password:") !!}
{!!Form::input("password", "usr_password", "mypass", ["class" => "form-control"]) !!}
</div>
<div class="form-group">
{!!Form::submit("Login", ["class" => "btn-primary form-control"]) !!}
</div>
{!! Form::close() !!}
#include("errors.list")
#stop
So a nonsense answer to resolve my problem: I cutted the code inside login.blade.php, save file, pasted it, and saved another time. Now it display correctly.

Laravel - global navigation

I have a navigation section built from a loop of my companies model.
So the nav looks like this
#foreach ($companies as $company)
{{ link_to("company/{$company->id}/users", $company->name, ['class' => 'btn btn-xs btn-primary']) }}
#endforeach
This grabs all of the company names and id's to build the button links for each company.
this works fine on my companies view, but I also want to include this in the main layout navigation.
What is the best why to do this? I was thinking to add a function to the base controller but not sure how or what view to return?
Create a file, you can name something like views/partials/companies.blade.php and add your foreach in it:
#foreach ($companies as $company)
{{ link_to("company/{$company->id}/users", $company->name, ['class' => 'btn btn-xs btn-primary']) }}
#endforeach
Then, everywhere you need it, you just have to tell Blade to include that partial:
#include('partials.companies')
Having your data globally available for this partial would require a View Composer:
View::composer(array('your.first.view','your.second.view'), function($view)
{
$view->with('companies', Company::all());
});
You can create a file to store your composers, something like app/composers.php and load it in your app/start/global.php:
require app_path().'/composers.php';

Resources