How to solve "NotFoundHttpException in RouteCollection.php line 161 on godaddy server - php

NotFoundHttpException in RouteCollection.php line 161. Here is my route code it's working fine on localhost but when i am trying to access my route on godaddy server i am getting notfoundhttpexception here is my route code.
Route::get('/customers','Controller#mainpage');
Route::get('/products','Controller#productpage');
Route::get('/brokers','Controller#brokerpage');
Route::get('/trucks','Controller#truckpage');
Route::get('/workers','Controller#workerpage');
My controller code is below.
public function mainpage()
{
$data['tableresult']=DB::table('customers')->get();
return view('main',$data);
}
public function productpage()
{
$data['tableresult']=DB::table('products')->get();
return view('products',$data);
}
public function truckpage()
{
$data['tableresult']=DB::table('trucks')->get();
return view('truck',$data);
}
public function brokerpage()
{
$data['tableresult']=DB::table('broker')->get();
return view('broker',$data);
}
This url is working fine on localhost
http://localhost:82/logistic/public/customers
When i am trying to access my project on live server i am getting notfoundhttpexception here is the url of live server
http://www.welcometransports.com/public/customers

Related

I can't create a view in Laravel

I'm new in Laravel and I'm trying to create a View in Acelle (app based on Laravel). I read a lot of tutorials, but I've not been luck with this problem.
I created the view "lol.blade.php" on /resources/views folder with this code:
HELLO (just hello)
The Route:
Route::get('lol', function()
{
if (view()->exists('lol')) {
//return 'helloooo'; <--- it works
return view('lol');
} else {
return 'not exists';
}
});
The code knows the view exists, but the url (localhost/acelle/public/lol) prints this message:
"Whoops, looks like something went wrong."
I can't solve the problem with tutorials. I followed all the steps about creating views in Laravel, but I don't know why the view prints that message.
Please help!
PS: Laravel version: 5.2.45
EDIT:
In console [network] shows Error 500. and laravel.log prints 59 lines. but the first line show:
[2017-07-14 14:08:20] production.ERROR: ErrorException: Undefined index:controller in /home/acelle/public_html/acelle/app/Providers/AppServiceProv‌​ider.php:20
You posted this in the comments:
app('view')->composer('*', function ($view) {
$action = app('request')->route()->getAction();
$controller = class_basename($action['controller']);
list($controller, $action) = explode('#', $controller);
$view->with(compact('controller', 'action'));
});
Your issue is that this route uses a closure, and has no controller:
Route::get('lol', function() {});
Therefore, $action['controller'] doesn't exist and throws a warning as a result. You'll want to check isset($action['controller']) before doing the rest of your code that uses the controller variable.
Already solved!!
SOLUTION:
creating a controller : MiwebController.php
<?
namespace Acelle\Http\Controllers;
class MiwebController extends Controller
{
public function __construct()
{
parent::__construct();
$this->middleware('auth');
}
public function index()
{
return view('lol');
}
}
?>
routes.php:
Route::get('lol', 'MiwebController#index');
It works fine. Thank you!

Laravel Mail:: inside function creates error

I am making my own package.
I simplified the code to explain the weird error.
I have a simple method inside a simple controller. First, i am sending an email (printing in laravel.log) and works fine.
public function signup(){
Mail::send('vendor.proto.register.emails.proto-register-new-account', [], function ($m) {
$m->from('noreply#test.com', 'Hello');
$m->to('sfs#dgf.c', 'pepe')->subject('Test. Congratulations, your account was created');
});
return view('view path');
}
But when i want to move the Mail:: to a private method like this.
public function signup(){
$this->sendNotification2();
return view('view path');
}
public function sendNotification2(){
Mail::send('vendor.proto.register.emails.proto-register-new-account', [], function ($m) {
$m->from('noreply#test.com', 'Hello');
$m->to('sfs#dgf.c', 'pepe')->subject('Test. Congratulations, your account was created');
});
}
It crash an print the error
FatalErrorException in ClassLoader.php line 373: Maximum function nesting level of '100' reached, aborting!
Is it a bug? or i am doing something wrong ?
Solution.
Googling i found this solution. Notice i am using laravel 5.2 and php 5.6.7
Add in bootstrap\autoload.php this code ini_set('xdebug.max_nesting_level', 200); and it fix the problem.

Laravel HTTP status code "1" is not valid error

I'm trying to access my url at: http://localhost/app/public/questions/1
My Routes
$this->get('/questions/{question_id}','questionController#show');
My controller
public function show($question_id) {
$showQuestion=questions::findOrFail($question_id);
return redirect('questions',compact('showQuestion'));
}
For some reason I'm getting this error
InvalidArgumentException in Response.php line 458:
The HTTP status code "1" is not valid.
What could be the problem?
I guess you are trying to return a view
public function show($question_id) {
$showQuestion=questions::findOrFail($question_id);
return view('questions')->with('question', $showQuestion);
}
Source
After having something similar myself, maybe you should be using:
return redirect('questions')->with('showQuestion', $showQuestion);

Decoding %2F Laravel 5

i have this url that return a json format
http://localhost/myproject/public/report/json/barcode/101-2016-10605030-001-1%2F2 but i get a
NotFoundHttpException in RouteCollection.php line 145
This is my Controller
public function barcode($val)
{
return rawurldecode($val);
}
what i need to display :
101-2016-10605030-001-1/2
I already :
AllowEncodedStatus On
Though its working on a regular php code (Not in Laravel)
Replace %2F to %252F:
public function barcode($val)
{
return $val;
}

Undefined variable Error Laravel only on Live Server

I am working on a custom Laravel Project.
I am getting following error:
Undefined variable: count_pandding (View: /domains/web4/html/manager/app/views/admin/home.blade.php)
but strange thing is this error does not show in localhost and works perfectly only in life server.
I have tried passing variables in 2 ways:
public function home()
{
$count_pandding = \Postjob::where('approve',0)->get()->count();
$count_disapprove = \Postjob::where('approve',2)->get()->count();
$count_approve = \Postjob::where('approve',1)->get()->count();
$count_expire = \Postjob::where('approve',3)->get()->count();
return View::make('admin.home', compact('count_pandding','count_disapprove','count_approve','count_expire'));
}
and 2nd way
public function home()
{
$data['count_pandding'] = \Postjob::where('approve',0)->get()->count();
$data['count_disapprove'] = \Postjob::where('approve',2)->get()->count();
$data['count_approve'] = \Postjob::where('approve',1)->get()->count();
$data['count_expire'] = \Postjob::where('approve',3)->get()->count();
return View::make('admin.home',$data);
}
None of it works in Life Server! But works perfectly in Localhost.
Please review Larvel Response
The second parameter of make is an array with key value bindings. I find it strange that this is working on your local machine.
Try
return View::make('admin.home', [
'count_pandding' => $count_pandding,
...
]);
Or
return View::make('admin.home')->withCountPannding($count_pannding);
//this becomes $countPannding in your view
Update:
return View::make('admin.home')->with($keyValueArray);
//should also translate into $key inside the view.

Categories