Where is the notification push code on Laravel - laravel

Sorry for asking this question. I'm new to laravel and I'm trying to find out the location of the responsible script of sending the notification on submite button event.
When I go to
http://127.0.0.1:8000/push-notificaiton
You know there you fill the title and message then you submit it to a script or code where you find the targeted auth username.
I want to know the location of that code to edit it in order to do one more things such as inserting title and message in database after sending the push notification to use.

For laravel 4.2
Go to app/routes.php. Search for 'push-notificaiton'. You will find a controller and function next to the url. Go to the controller and find the function
For laravel 5 - 5.2
app/Http/routes.php
From version 5.3 - 8
routes/web.php

In your routes/web.php file, you should find a route for that URL. You'll also find the name of a controller next to it. Open up that controller and you'll see the code for the route.

Related

Laravel determine which controller returned error , laravel breeze

I'm using laravel breeze and I have two popups modals in the header, one for login and one for signup, when an authentication error occurs I want to: A) open the modal responsible and B) show the error in the correct modal, any ideas?
I solved it using $request->validateWithBag instead of $request->validate and checked for the "Bag" in script section with $errors->nameOfBag->has('email') and it worked as needed

how to add or edit gravitar within laravel

I know that we can user the gravitar in laravel for display pic but how can we add one if the new user doesn't have it or wish to update the current one from within the application?
below article shows how to show existing gravitar in laravel.
How do I implement Gravatar in Laravel?
You can supply a default image through the Gravatar URL.
Documentation.

Laravel 5.8 Manual user approval?

I am new to laravel and before asking this question. I have read various other topics regarding this question sadly none of them helped me.
I have laravel 5.8 and use auth which I installed with:
php artisan make:auth
Now I read that I either need to make a middleware or edit the logincontroller. But what I want is the user to be redirected to a custom page that I already made saying they need to wait to be approved.
Could someone point me in the right direction and tell me which files I need to edit to achieve this?
I have already added a BIT column in the database table called is_approved which is auto set to 0.
In your
App/Htpp/Controllers/Auth
you'll find all the logic of authentication and registration of the user. Inside the controllers, you'll see this:
/**
* Where to redirect users after verification.
*
* #var string
*/
protected $redirectTo = '/home';
Last line is what you're looking for, it's pointing the view/route where your user will be redirected after the respective action.
Also, all your generated views when you run the make:auth command will be in
resources/views/auth
if you feel the need to modify them.
Go here. HomeController. Under return view('home'); change it to
if (Auth::user()->is_approved === "1"){
return view('home');
} else {
return view('welcome');
}
Where 'welcome' you can change to your custom page and '1' assumes the user has been approved. Remember to add use Illuminate\Support\Facades\Auth; to the top of that controller. I had that problem and came to read your post. Thought to drop what I did. It works for me
You need to build a user approval system. A common way is store an active state on the users table as a boolean MySQL column. Then check that column if a user tries to login. As for registration you need to write to the users table with an active state of 0 or false. It would be also great to trigger a notification to you the admin that "hey, you need to go approve a new user". It could be handled through Laravel Nova dashboard where ideally you only need to click a button.
It's not built into the Laravel framework but definitely seems like a good use case!

Laravel 5.1 UrlGenerator route not defined error

I have an app built with Laravel 5.1. I'm using Form::open using a route_name to generate the url to post the form to as well as creating links by defining route and using the UrlGenerator. The issue is that I have some buttons/links created for display purposes and do not have pages created yet.
I get a route not defined error with stack trace going back to UrlGenerator line 296. I'm wanting to set up something so that the error does not display. Instead, I would like a link to be generated to the pre-defined page that I have created saying that the feature the user clicked on is not yet developed.
I thought about doing something similar to a 404 error, but the issue is that the existing page (the page the link or button lives on) is not being displayed, not just that route is missing.
For example, below, I create a link to the route "broker_contact_create" Since this route does not exist, the page displaying the link will not load. Instead, I get the error saying:
ErrorException in UrlGenerator.php line 296: Route
[broker_contacts_create] not defined. (View:
index.blade.php)
<div class="col-md-6 col-lg-7 margin-bottom-15">
+ Add Contact
</div>
Instead, I want the page to be displayed. When the user clicks on the link to a missing route, to have them routed to a page that tells the user they clicked on a link to a feature that has not been enabled yet.
So basically I just want it to do: if route not found then provide $url.
If you follow the stack trace, you'll see that the route function basically invokes UrlGenerator->route
https://github.com/laravel/framework/blob/5.1/src/Illuminate/Routing/UrlGenerator.php#L300
Which checks if the route with that name exists, and if not, throws an InvalidArgumentException.
Basically, what you're trying to do is not possible. You must define that route if you want to use the route function.
I think your best option is to set up a "feature not developed" view, and point all of these pending routes to that view. That way you can use the route function. Your link/button will be generated, but will take them to a "not yet developed" page. Another benefit to this is that all of your routes are laid out and you can easily see which ones need to be developed.
Route::get('/brokers/contacts/create', ['uses' => 'HomeController#notDeveloped', 'as' => 'broker_contact_create']);
And inside your HomeController:
public function notDeveloped() {
return view('pages.not_developed');
}

Codeigniter - Htaccess : How to change a controller name

This is my first question here, so Hi all! ^^
I created a website with codeigniter framework and I have inserted a module for multilanguage. The url looks like this:
http://www.mywebsite.com/en/controller/function
The problem came when the client wanted to send a newsletter to all its customers in another language, but do not want to send the url with the controler with the name in english, because the newsletter is for spanish users.So:
URL is going to be send:
http://www.mywebsite.com/es/thecontroller
URL the client wants to be send ("elcontrolador" is "thecontroler" in spanish):
http://www.mywebsite.com/es/elcontrolador
I dont want to create another controler named "elcontorlador" only to show the same page as "thecontroler", because we don't want duplicate content for SEO purposes.
So, i want via .htaccess, a rule that when i type
http://www.mywebsite.com/es/elcontrolador
in the URL, mywebpage shows the info of
http://www.mywebsite.com/es/thecontroler
but with the URL
http://www.mywebsite.com/es/elcontrolador
(the controler "elcontrolador" doesnt exist).
So, is there any way to do this with the htaccess? I've tried it myself but I failed miserably i come here desperate, because I run out of time to deliver it and can not find a viable solution. I'll have to create the extra controller?
Need help D:
Maybe you can use the route config file instead to achieve this ?
$route['es/elcontrolador'] = 'es/thecontroler';
I don't know how you handle your multilangage, but you've got the idea.

Resources