I tried to get an answer from the laracast community but ended up not getting a response. I get the following text output at the top of every page or CLI command:
Skip to content Personal Open source Business Explore Pricing Blog Support This repository
3,019 22,483
7,384
laravel/laravel Code Pull requests 0 Pulse Graphs
laravel/config/database.php eb7743f 11 days ago #dakira dakira allow
for setting sqlite database via env #taylorotwell #TGM #vlakoff
#dakira #marcanuy #pedes42 #jimmypuckett #GrahamCampbell
#david-ridgeonnet #SyntaxC4 #overtrue 121 lines (101 sloc) 3.84 KB
All of the files that may be suspect are available in the laracast discussion I posted.
C4 #overtrue
121 lines (101 sloc) 3.84 KB
BTW I used composer to install laravel.
EDIT routes.php file
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'PagesController#index');
Route::get('item', 'ItemController#index');
Route::get('item/create', 'ItemController#create');
Route::get('item/{id}', 'ItemController#show');
Route::get('welcome', function() {
return view('welcome');
});
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/home', 'HomeController#index');
});
Route::post('item', 'ItemsController#Store');
Related
I'm trying to work with some ajax inside of laravel, still quite new to all of it, but I've noticed that for some reason everytime I create a new route I get a 404 regardless of what it is that I'm doing. For example, something as simple as:
Route::get('templateswitch', function() {
return 'Hello World';
});
Will still return out a 404, it is listed in the routes, and I've tried running the optimization through artisan too, so far no dice.
I'm not sure if it's just something I'm doing wrong in the code or something wrong with my server.
Any help would greatly be appreciated!
Full web.php
<?php
use App\Http\Controllers\SwitchController;
use App\Http\Controllers\TemplateSwitch_Controller;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('templateswitch', function() {
return 'Hello World';
});
Route::post('/switch', [TemplateSwitch_Controller::class, 'ajaxGetByID'])->name('test_templateswitch');
Route::get('/', [TemplateSwitch_Controller::class, 'index']);
I'm trying to render a view but I always get notfoud 404 I don't know how to solve this question anymore if anyone can help me I would be grateful.
any help is welcome.
Thanks in advance.
Everyone have a great Monday.
CommunityPostController -> code ->
public function creategif(Community $community)
{
return view('posts.creategif', compact('community'));
}
Web Routes
Route::get('/', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::get('u/{id}', [App\Http\Controllers\HomeController::class, 'user'])->name('user.view');
Auth::routes(['verify' => true]);
Route::group(['middleware' =>['auth', 'verified']], function (){
Route::resource('communities', \App\Http\Controllers\CommunityController::class);
Route::resource('communities.posts', \App\Http\Controllers\CommunityPostController::class);
Route::resource('posts.comments', \App\Http\Controllers\PostCommentController::class);
Route::get('communities/{community}/posts/creategif', [\App\Http\Controllers\CommunityPostController::class, 'creategif']);
Route::get('posts/{post_id}/vote/{vote}', [\App\Http\Controllers\CommunityPostController::class, 'vote'])->name('post.vote');
});
Views Files Structure
There might be a conflict base on your route order and the image you've posted. As you can see you have resource for your route which in this case this conflict might happen base on route order, and your laravel is actually trying to get a post instead of loading creategif route.
Which in this case every time you try to get access to creategif route, your application is actually trying to load a post base on 'communities.posts' route.
So base on this conflict in your route order, this is working fine and create or any other routes related to 'communities.posts' should work fine, but in other-hand creategif in URL might recognized as a route related to 'communities.posts' resource.
Move your route to top, or in this case just above 'communities.posts' route, don't forget to clear route cache.
Route::group(['middleware' =>['auth', 'verified']], function (){
Route::get('communities/{community}/posts/creategif', [\App\Http\Controllers\CommunityPostController::class, 'creategif']);
Route::resource('communities', \App\Http\Controllers\CommunityController::class);
Route::resource('communities.posts', \App\Http\Controllers\CommunityPostController::class);
Route::resource('posts.comments', \App\Http\Controllers\PostCommentController::class);
Route::get('posts/{post_id}/vote/{vote}', [\App\Http\Controllers\CommunityPostController::class, 'vote'])->name('post.vote');
});
I'm using Laravel 9 with Inertia and VueJs. I'm trying to paginate my invoices, and the links display as expected when I load the page (http://localhost:3000). However, when I click on a button to go to the next page (or any other page from the pagination), all the links change to:http://localhost/. I don't know how to solve this.
InvoiceController
$invoices = Invoice::latest()
->with('customer:id,name')
->orderByDesc('invoice_date')
->paginate(10);
return Inertia::render('Invoices', ["invoices" => $invoices]);
.env
APP_URL=http://localhost:3000
DEV_URL=http://localhost:3000
webpack.mix.js
// ...
.browserSync("localhost");
config/app.php
'url' => env('APP_URL', 'http://localhost:3000'),
Update
A github issue is opened: https://github.com/inertiajs/inertia/issues/811
i bought a laravel script
it's working fine but any route i try to add i get error
here is simple route
Route::get('/greeting', function () {
return 'Hello World';
});
not working but dashboard is working anything in the script work fine but adding any route i get that error
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Auth::routes();
Route::group(['middleware' => 'auth'], function() {
Route::get('/dashboard', 'HomeController#dashboard');
});
Route::get('/greeting', function () {
return 'Hello World';
});
As mentioned in the comment by IGP, you should try to clear the route cache first.
If that does not help, you should take a look at the RouteServiceProvider to make sure that your route file gets called from there.
You can also try to adjust the order (if more than one routing file is called) so that your route file is evaluated before the others (the first matching route "wins").
Also please check the route config of the bought script as it could contain a catch-all/wildcard route.
IGP solution work fine it was a cache problem
thank you
I just prepared this nice shopping website code
https://github.com/drehimself/laravel-ecommerce-example
I go admin page then upload some new items but
those item data and images are not dislayed.
I tryed to look contoller page but I couldn't find where are at.
Here is the web.php file
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
});
Could somebody teach me where should I change?
You can view all routes from
vendor\TCG\Voyager\routes\voyager.php
If you want to override any route then update in web.php