laravel-5.6

How to override default login mechanism of Laravel 5.6?

时光怂恿深爱的人放手 提交于 2019-12-05 18:34:45
I want the user to login only if status field in users table is set to 1 . If it is 0 then simply return error stating user account is not active . So after creating the status field in the table, where can I make the check that the user'status is 1 then only login otherwise throw error. I tried to find where the default auth check is made but cannot find it anywhere. You need to simply override credentials() which is defined in AuthenticatesUsers.php . the default login method use AuthenticatesUsers trait. so go login controller and overwrite like this. protected function credentials(Request

Laravel Passport Multiple Authentication using Guards

眉间皱痕 提交于 2019-12-05 08:26:45
问题 Can we use laravel passport with different guards to authenticate APIs for two different types of users. For example we have driver app for driver user and vendor app for vendor user. Both have their different models Driver and Vendor. How can we use different guards to authenticate both types of users using Laravel Passport? 回答1: Here is an example of auth.php and api.php to start with config/auth.php <?php return [ /* |------------------------------------------------------------------------

JWT/LARAVEL token expired

只愿长相守 提交于 2019-12-04 22:05:10
I developed an API and I have a problem with the expiration of the token, and I try to find ways to refresh the tokens sent by API and I found nothing This is my user mdoal: <?php namespace App; use Tymon\JWTAuth\Contracts\JWTSubject; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable implements JWTSubject { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password','username','lastname','tel','tel', ]; /** * The attributes that should be

Laravel 5.6 pass oauth/token hanging

不问归期 提交于 2019-12-04 06:21:19
问题 I have set up a new laravel 5.6 install with Laravel Passport install. If I make a post request to http://127.0.0.1/oauth/token with Postman I get a valid token back: Request POST /oauth/token HTTP/1.1 Host: 127.0.0.1:8000 Content-Type: application/json X-Requested-With: XMLHttpRequest Cache-Control: no-cache Postman-Token: 99529c07-0fe3-38a8-54cf-8b80a9dd5fbd { "grant_type" : "password", "client_id" : 4, "client_secret" : "Ib1UOS7BK12tFxOilqwea1XGJhrExbVYe8B7r8wK", "username" : "mail@mail

Want to implement web sockets in Laravel

别说谁变了你拦得住时间么 提交于 2019-12-04 03:01:31
I want to implement web notifications in Laravel using web sockets. I have tried pusher. It is very easy but it is a paid package. I have also tried redis and socket.io for which I have to install horizon. I am running Windows and I cannot install it on Windows according to what I have read about horizon. So I am very confused about push notification. I am trying for at least one week but haven't found any solution yet. My front end is in angluar 5/android and backend is in Laravel 5.6. Can you please suggest me any good ideas to implement push notification? You have been use pusher,so I

Laravel 5.6 - Pass additional parameters to API Resource?

帅比萌擦擦* 提交于 2019-12-03 12:49:07
问题 A Laravel API Resource can be either a single resource or a collection. In some cases, additional parameters are required to be passed to the resource/collection from the controller. Below is a simple example demonstrating the issue using User as a single/collection resource, and a custom $apple parameter to be passed to the resource for output. The issue can be seen in the final Output (Collection) below, where for the fruit value, we get an incorrect value of banana for the first user,

laravel remember me not working

旧巷老猫 提交于 2019-12-03 09:41:44
I have created 2 different login forms for admin and users in admin login form i have used attempt function i want to use remember me functionality but when i log in to the system without clicking remember me checkbox i can see in database it stores some value is it normal that its storing values not checking remember me token ? this is my code for admin login if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) { // if successful, then redirect to their intended location return redirect()->intended(route('admin.dashboard')); }

How can I convert conditional aggregation mysql to laravel query?

試著忘記壹切 提交于 2019-12-02 20:27:50
问题 My sql query like this : SELECT a.number, a.description, MAX(CASE WHEN b.attribute_code = 'brand' then b.attribute_value END) as brand, MAX(CASE WHEN b.attribute_code = 'model' then b.attribute_value END) as model, MAX(CASE WHEN b.attribute_code = 'category' then b.attribute_value END) as category, MAX(CASE WHEN b.attribute_code = 'subcategory' then b.attribute_value END) as subcategory FROM items a JOIN attr_maps b ON b.number = a.number GROUP BY a.number, a.description HAVING brand = 'honda

How to add data to all log records in Laravel 5.6?

余生颓废 提交于 2019-12-02 18:11:53
问题 How to add data to all log records in Laravel? answers how to add data to all log records in Laravel 5.5 and earlier. e.g. the following is added to AppServiceProvider::register(): $monolog = \Log::getMonolog(); $monolog->pushProcessor(function ($record) { $record['extra']['ip'] = \Request::getClientIp(); $record['extra']['path'] = \Request::path(); return $record; }); This doesn't work for Laravel 5.6. I looked through the documentation for 'creating custom channels' but didn't see any

How can I redirect back to previous page after login on vue and laravel?

无人久伴 提交于 2019-12-02 13:43:11
问题 I use vue.js 2 and laravel 5.6 My vue component like this : <template> <a v-if="auth" href="javascript:" class="btn btn-default btn-block" @click="add($event)"> Add </a> <a v-else href="javascript:" class="btn btn-default btn-block" @click="logout"> Add </a> </template> <script> export default { data() { return { auth: App.authCheck } }, methods: { add(event) { ... }, logout() { window.location = '/login?red='+window.location.pathname } } } </script> If the user is not logged in, it will call