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;
}
Related
I used to create functions in controllers like this with Laravel 5.8 and I was able to handle when the item was not found redirecting the user to the index page with an error notification.
public function edit($id)
{
$template = Template::find($id);
if ($template) {
return view('admin.templates.edit', compact(['template']));
}
$this->setNotifications('error', 'Not found');
return redirect()->route('admin.templates.index');
}
Now with Laravel 6 the function declaration has changed and if the item is not found, it displays the default not found page directly, ignoring the code in the function and I'm not able handle the not found error as I used to do.
public function edit(Template $template)
{
if ($template) {
return view('admin.templates.edit', compact(['template']));
}
$this->setNotifications('error', 'Not found');
return redirect()->route('admin.templates.index');
}
Is there a way to use the Laravel 6 way and handle what happens when the item is not found at the same time?
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!
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
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);
This is my URL:
http://serverHost:port/projectName/public/restaurants/create
This is the error message:
Open: UrlToProject\bootstrap\compiled.php
if (!is_null($route)) {
return $route->bind($request);
}
$others = $this->checkForAlternateVerbs($request);
if (count($others) > 0) {
return $this->getOtherMethodsRoute($request, $others);
}
throw new NotFoundHttpException();
}
protected function checkForAlternateVerbs($request)
Though the route does exist like this:
Route::resource('restaurants', 'RestaurantsController');
and the controller RestaurantsController has this method:
public function create()
{
return View::make('restaurants.create');
}
and the view absolutely exists. What am I doing wrong please?
I am working on Laravel 4.2.3 on Windows 7.
Also, I noticed these lock signs. is this wrong?
I found the problem myself
The project name has a capital letter case and I was calling it small letter :)