those are my routes and all send me to welcome blade; for example, if I try to go to about. blade it end up in welcome blade
Route::group(['prefix' => '{locale}'],function(){
Route::get('/','Room_randring_welcom#index')->name('post')->middleware('setLocale');
});
Route::get('/about', function () {
return view('aboutUs');
});
Route::get('/rooms', function () {
return view('Room');
});
Route::get('/contact','Email_send#contact');
Route::post('/contact','Email_send#Contact_Submit')->name('Contact.submit');
Route::get('/Gallery', function () {
return view('Gallery');
});
Route::get('/room_detail', function () {
return view('room_details');
});
Related
I have a route for tenants name like that:
example.test/TenantNameHere
And I want to make the default of my domain start with the word "site":
example.test/site
My code:
Route::prefix('{tenantName}')->group(function () {
Route::get('/', function ($tenantName) {
return "{$tenantName}";
});
});
Route::prefix('site')->group(function () {
Route::get('price', function () {
return view('welcome');
});
});
Route::redirect('/', 'site', 301);
The problem that I'm facing with this code now is when I open the domain it redirects me to tenantName route, not to the home page that I made!
How can spreate the route of site from TenantName ?
you just have to register your absolute path ('site') first, and "wildcards" routes after, because everything you put in url line now hit the first tenantName route
try this (reverse the order):
Route::redirect('/', '/site', 301);
Route::prefix('site')->group(function () {
Route::get('/', function () {
return view('welcome');
});
});
Route::prefix('{tenantName}')->group(function () {
Route::get('/', function ($tenantName) {
return "{$tenantName}";
});
});
also change "/site/price" path to "/site", so redirect will find correct route
Normally everything works fine on localhost. When I throw the project to the server, only the homepage works.
When I add manually to this section from the database, I can pull the data.
web site here: http://elsetea.com/public (running)
but when I want to log in to my admin panel from this page (http://elsetea.com/public/login) routing does not work properly and it gives an error.
Why can you think? Please help me. Very Thanks.
Username: admin#admin.com
Password: admin
You can see some routing below.
web.php
Auth:
:routes();
Route::namespace('Frontend')->group(function () {
Route::get('/', 'HomeController#index')->name('home.index');
// Route::get('/home', 'HomeController#index')->name('home');
});
Route::namespace('Frontend')->group(function () {
Route::get('service', 'ServicePageController#index')->name('service-page.index');
});
Route::namespace('Frontend')->group(function () {
Route::get('portfolio', 'PortfolioPageController#index')->name('portfolio-page.index');
Route::get('portfolio/{slug}', 'PortfolioPageController#show')->name('portfolio-page.show');
});
Route::namespace('Frontend')->group(function () {
Route::post('comment', 'CommentController#store')->name('comment.store');
});
Route::namespace('Frontend')->group(function () {
Route::post('contact', 'ContactPageController#store')->name('contact-page.store');
});
Route::namespace('Frontend')->group(function () {
Route::get('aboutus', 'AboutusPageController#index')->name('aboutus-page.index');
});
Route::namespace('Frontend')->group(function () {
Route::get('blog', 'BlogPageController#index')->name('blog-page.index');
Route::get('blog/{slug}', 'BlogPageController#show')->name('blog-page.show');
Route::get('blog/category/{category_name}', 'BlogPageController#category_show')->name('blog-category.show');
});
Route::middleware(['auth.admin'])->group(function () {
Route::get('admin-panel/dashboard', 'HomeController#index')->name('dashboard');
});
Route::namespace('Admin')->middleware(['auth.admin'])->group(function () {
Route::get('admin-panel/profile/edit', 'ProfileController#edit')->name('profile.edit');
Route::put('admin-panel/profile/{id}', 'ProfileController#update')->name('profile.update');
Route::get('admin-panel/profile/change-password', 'ProfileController#change_password_edit')->name('profile.change_password_edit');
Route::put('admin-panel/profile/change-password/update', 'ProfileController#change_password_update')->name('profile.change_password_update');
});
Route::namespace('Admin')->middleware(['auth.admin'])->group(function () {
Route::get('admin-panel/site-info', 'SiteInfoController#create')->name('site-info.create');
Route::post('admin-panel/site-info', 'SiteInfoController#store')->name('site-info.store');
Route::put('admin-panel/site-info/{id}', 'SiteInfoController#update')->name('site-info.update');
});
Route::namespace('Admin')->middleware(['auth.admin'])->group(function () {
Route::get('admin-panel/homepage-version', 'HomepageVersionController#create')->name('homepage-version.create');
Route::post('admin-panel/homepage-version', 'HomepageVersionController#store')->name('homepage-version.store');
Route::put('admin-panel/homepage-version/{id}', 'HomepageVersionController#update')->name('homepage-version.update');
});
i have some function that check something and give back in some cases "exit();".
i want to use it inside Route::group.
how can i do it right without it impact all the other routes? thanks!
Route::group(['middleware' => ['auth:api']], function() {
myFunction (); //this function can give back: exit();
Route::get('/test', 'Api\Test#test');
});
Turn your function into middleware: https://laravel.com/docs/5.8/middleware
Group the routes that must be affected by your check, and leave out the routes that don't.
Route::group(['middleware' => ['auth:api']], function() {
Route::group(['middleware' => ['MyMiddleware']], function() {
Route::get('/check-me', 'Api\Test#test1');
});
Route::get('/dont-check-me', 'Api\Test#test2');
});
i am new to laravel, i managed to deploy my laravel project on godaddy shared hosting, it works perfectly... but the domain doesnt work...
this is the nature of my routes/web.php
<?php
Route::group(['domain' => 'example.com'], function(){
Route::get('/', function () {
return view('welcome');
});
});
Route::group(['domain' => 'cars.example.com'], function(){
Route::get('/', function () {
return view('cars');
});
});
so, whenever i try accessing cars.example.com, it brings the error "500 internal server error"
guys i need your help on this one, thanks
This works for me but I am not using godaddy.
// All subdomain routes
Route::group(['domain' => 'cars.example.com'], function () {
Route::get('/', function () {
return view('cars');
});
});
// All domain routes
Route::get('/', function () {
return view('welcome');
});
If you want to get fancy you could do this.
// Captures all sub domains
Route::group(['domain' => '{subdomain}.example.{tld}'], function () {
Route::get('/', function () {
return view($subdomain);
});
});
// All domain routes
Route::get('/', function () {
return view('welcome');
});
so I have an ajax call to a contoller which is logging me in, I know this is working because of Auth::check($user) and the returned cookie data, such as the laravel session cookie.
However, my problem is in my routes.php, I still can't get to the authorized only pages, and keep hitting the welcome view.
My routes.php:
use App\punsmodel;
use Illuminate\Http\Request;
Route::post('google' , [
'as' => 'verify.index',
'uses' => 'verify#verifyIdToken'
]);
if (Auth::guest()) {
Route::get('/', function () {
return view('welcome');
});
} else {
Route::group(['middleware' => 'auth'], function () {
Route::get('/', function () {
return view('mainview');
});
Route::get('mainview', function () {
return view('mainviewMolly');
});
});
}
My controller:
namespace App\Http\Controllers;
use App\Email;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Google_Client;
use Auth;
use App\User;
class verify extends Controller
{
public function verifyIdToken(Request $request)
{
$user = User::where('name', 'Molly')->first();
Auth::login($user);
if (Auth::check($user))
{
return response()->json(['Logged In' => "Yes!"]);
}
}
}
So I do an ajax request to the above controller, which works as I get the json response that says I was logged in, however then when I refresh the homepage, I still get the welcome page not the mainview. Why is this the case?
My ajax request:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
method: "POST",
url: "http://mysite.come/google",
data: { email: profile.getEmail(),
id: id_token }
}).done(function() {
$("#google").text("You Are Indeed Who I Thought You Were! :)");
}).fail(function() {
$("#google").text("You Are Not Who I Thought You Were, Please Go Away!");
setTimeout(function() {
window.location = "https://en.wikipedia.org/wiki/Special:Random";
//}, 4000);
}, 9999999000);
})