How can i use Laravel Auth and Vue-Router?

|
2019-04-07 18:31:11
Hi there, I am trying to make submission management system with 5 types of user handled in one table (users-table)

here is my class CreateUsersTable:
public function up()
{
Schema::create(‘users’, function (Blueprint $table) {
$table->increments(‘id’);
$table->enum(‘isAdmin’, [4, 3, 2, 1, 0])->default(0);
$table->string(‘name’);
$table->string(’email’)->unique();
$table->timestamp(’email_verified_at’)->nullable();
$table->string(‘password’);
$table->rememberToken();
$table->timestamps();
});
}

I want to set every single type of user [4,3,2,1,0] has different home/dashboad page. How can I make middleware to manage user access and redirect those 5 type of user to their home/dashboard page is there any body have tutorial how to do this?

josy_maid 2019-04-07 18:34:53
Hi guys, i need a little help
josy_maid 2019-04-07 18:35:28
laravel_discuss-4463.jpg

josy_maid 2019-04-07 18:36:12
I want to pass, customer id, with route method, How can I do?
rizkyarlin 2019-04-07 19:25:05
Use the route method with customer as the second argument after the route name
rizkyarlin 2019-04-07 19:29:37
Take a look at https://laravel.com/docs/5.8/helpers#method-route

Laravel – The PHP Framework For Web ArtisansLaravel
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
espari 2019-04-07 19:31:31
josy_maid 2019-04-07 18:36:12
I want to pass, customer id, with route method, How can I do?

set name for route ,for example : single_customer

then

href={{route(‘single_customer’,$customer->id)}}

d3UsPr0 2019-04-07 19:42:09
hi, am new here.
any one with laravel tutorials
d3UsPr0 2019-04-07 19:42:28
for bigginers
loveycom 2019-04-07 19:48:19
2019-04-07 18:31:11
Hi there, I am trying to make submission management system with 5 types of user handled in one table (users-table)

here is my class CreateUsersTable:
public function up()
{
Schema::create(‘users’, function (Blueprint $table) {
$table->increments(‘id’);
$table->enum(‘isAdmin’, [4, 3, 2, 1, 0])->default(0);
$table->string(‘name’);
$table->string(’email’)->unique();
$table->timestamp(’email_verified_at’)->nullable();
$table->string(‘password’);
$table->rememberToken();
$table->timestamps();
});
}

I want to set every single type of user [4,3,2,1,0] has different home/dashboad page. How can I make middleware to manage user access and redirect those 5 type of user to their home/dashboard page is there any body have tutorial how to do this?

Have you solved it?

2019-04-07 19:49:41
loveycom 2019-04-07 19:48:19
Have you solved it?

No, still looking for some related tutorials, but I didn’t found it

loveycom 2019-04-07 20:01:43
Let’s assume all user access same route such as
Route::get(‘/dashboard’, ‘ControllerName@function’);

In the controller function, get user’s isAdmin value and write this conditional statement
if(isAdmin == 1){
return view(‘dashboard1);
} else if(…

rizkyarlin 2019-04-07 20:08:08
loveycom 2019-04-07 20:01:43
Let’s assume all user access same route such as
Route::get(‘/dashboard’, ‘ControllerName@function’);

In the controller function, get user’s isAdmin value and write this conditional statement
if(isAdmin == 1){
return view(‘dashboard1);
} else if(…

Because he is only evaluating one value, switch case is more efficient

rizkyarlin 2019-04-07 20:08:29
And the value is predefined
2019-04-07 20:11:04
rizkyarlin 2019-04-07 20:08:08
Because he is only evaluating one value, switch case is more efficient

I am really a newbie in laravel, and I don’t know how to do that, any tutorials how to use switch case?

rizkyarlin 2019-04-07 20:11:39
Balik ke KPM bro hahaha
rizkyarlin 2019-04-07 20:11:56
Switch case tuh dasar php, bukan di laravel…
2019-04-07 20:12:59
Yoi…
2019-04-07 20:13:09
Makanya saya pusing bro
2019-04-07 20:13:19
Bener” baru belajar
loveycom 2019-04-07 20:16:18
rizkyarlin 2019-04-07 20:08:08
Because he is only evaluating one value, switch case is more efficient

More efficient as how? He can use switch case if he likes or use if statement if he likes.

rizkyarlin 2019-04-07 20:24:07
loveycom 2019-04-07 20:16:18
More efficient as how? He can use switch case if he likes or use if statement if he likes.

Other than websites, I also do some IoT projects with constrained device. You will really feel the difference between if else and switch case there. You might be not able to really feel the impact of these two in web programming.

But still, take a look at this

rizkyarlin 2019-04-07 20:24:15
laravel_discuss-4487.jpg

2019-04-07 20:29:38
I just followed this attached link tutorial but it’s not working, is that because my laravel version I use laravel 5.8 https://stackoverflow.com/questions/39129759/laravel-redirect-different-user-roles-differently

Laravel: Redirect different user roles differentlyStack Overflow
Is it possible to redirect users with different user roles to a different page in laravel 5.1?

I have looked into Auth middleware and Auth controller, but found nothing that processes the login re…

2019-04-07 20:43:32
Here is my RedirectIfAuthenticated.php
<?php

namespace AppHttpMiddleware;

use Closure;
use IlluminateSupportFacadesAuth;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(‘/home’);
}
return $next($request);
}
}
How could I add switch case to my RedirectIfAuthenticated class to redirect user to different dashboar after login?

espari 2019-04-07 20:53:07
2019-04-07 20:43:32
Here is my RedirectIfAuthenticated.php
<?php

namespace AppHttpMiddleware;

use Closure;
use IlluminateSupportFacadesAuth;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(‘/home’);
}
return $next($request);
}
}
How could I add switch case to my RedirectIfAuthenticated class to redirect user to different dashboar after login?

this class check user login every request ,

2019-04-07 20:58:29
rizkyarlin 2019-04-07 20:24:07
Other than websites, I also do some IoT projects with constrained device. You will really feel the difference between if else and switch case there. You might be not able to really feel the impact of these two in web programming.

But still, take a look at this

I already found my solution. I fixed it with adding switch case in login controller. Thank U

josy_maid 2019-04-07 21:06:34
Thanks for all
josy_maid 2019-04-08 02:31:17
laravel_discuss-4494.jpg

josy_maid 2019-04-08 02:31:31
I have import the class
josy_maid 2019-04-08 02:31:40
But i have the error
josy_maid 2019-04-08 03:15:48
laravel_discuss-4498.jpg

josy_maid 2019-04-08 03:33:49
fix it
2019-04-08 06:07:17
josy_maid 2019-04-08 03:33:49
fix it

You didn’t import that in this controller

rei_yan 2019-04-08 07:13:48
How can i use Laravel Auth and Vue-Router ?
2019-04-08 08:24:25
rei_yan 2019-04-08 07:13:48
How can i use Laravel Auth and Vue-Router ?

You have to write auth api

rei_yan 2019-04-08 08:39:18
2019-04-08 08:24:25
You have to write auth api

also jwt ?
someone can give me example for this case ?

2019-04-08 09:02:28
rei_yan 2019-04-08 08:39:18
also jwt ?
someone can give me example for this case ?

https://codeburst.io/api-authentication-in-laravel-vue-spa-using-jwt-auth-d8251b3632e0

API Authentication in Laravel-Vue SPA using Jwt-authMedium
Introduction: Laravel is the fastest growing PHP framework and is used by thousands of developers around the globe to rapidly build robust…
Manoj Mehta 2019-04-08 10:19:15
laravel_discuss-4511.jpg
In my ionic app when I select image from gallery it’s upload on server but not show preview
Manoj Mehta 2019-04-08 10:19:44
Any one ionic developer here?
RajkotRocks 2019-04-08 10:33:06
Manoj Mehta 2019-04-08 10:19:44
Any one ionic developer here?

Yes

RajkotRocks 2019-04-08 10:42:29
Just copy paste
RajkotRocks 2019-04-08 10:43:06
parth87, 13:08 ionic cordova plugin add cordova-plugin-camera npm install –save @ionic-native/camera import { Camera, CameraOptions } from ‘@ionic-native/camera’; public camera: Camera const options: CameraOptions = { quality: 50, destinationType: this.camera.DestinationType.DATA_URL, encodingType: this.camera.EncodingType.JPEG, mediaType: this.camera.MediaType.PICTURE, correctOrientation: true, sourceType: this.camera.PictureSourceType.PHOTOLIBRARY } this.camera.getPicture(options).then((imageData) => { this.image = imageData; this.imgProfile = ‘data:image/jpg;base64,’ + imageData; }, (err) => { // Handle error }); <img [src]=imgProfile /> parth87, 13:09 addOne() { const options: CameraOptions = { quality: 50, destinationType: this.camera.DestinationType.DATA_URL, encodingType: this.camera.EncodingType.JPEG, mediaType: this.camera.MediaType.PICTURE, correctOrientation: true, sourceType: this.camera.PictureSourceType.PHOTOLIBRARY } this.camera.getPicture(options).then((imageData) => { this.image = imageData; this.imgProfile = ‘data:image/jpg;base64,’ + imageData; }, (err) => { // Handle error }); } from HTML <img [src]=imgProfile />
R_IT_Geek 2019-04-08 11:15:35
I have a many to many relationships for two user and product tables.

I called pivot table, a cart.

this is relationship code

return $this->belongsToMany(‘AppModelsProduct’, ‘carts’)->withPivot([‘uuid’, ‘user_ip’, ‘status’]);

When I run the following code, I get the following error.

$user->products()->attach([
‘product_id’ => $id,
‘uuid’ => Uuid::generate(4)->string,
‘user_ip’ => request()->ip(),
‘status’ => 1
]);

this is error:

SQLSTATE[HY000]: General error: 1364 Field ‘uuid’ doesn’t have a default value (SQL: insert into carts (product_id, user_id) values (3, 2), (2c443c9c-f724-420c-bfe8-6299d322e68d, 2), (192.168.1.20, 2), (1, 2))

StanleyMasinde 2019-04-08 11:17:05
R_IT_Geek 2019-04-08 11:15:35
I have a many to many relationships for two user and product tables.

I called pivot table, a cart.

this is relationship code

return $this->belongsToMany(‘AppModelsProduct’, ‘carts’)->withPivot([‘uuid’, ‘user_ip’, ‘status’]);

When I run the following code, I get the following error.

$user->products()->attach([
‘product_id’ => $id,
‘uuid’ => Uuid::generate(4)->string,
‘user_ip’ => request()->ip(),
‘status’ => 1
]);

this is error:

SQLSTATE[HY000]: General error: 1364 Field ‘uuid’ doesn’t have a default value (SQL: insert into carts (product_id, user_id) values (3, 2), (2c443c9c-f724-420c-bfe8-6299d322e68d, 2), (192.168.1.20, 2), (1, 2))

Make sure your primary keys are auto incrementing

R_IT_Geek 2019-04-08 11:21:26
StanleyMasinde 2019-04-08 11:17:05
Make sure your primary keys are auto incrementing

yes there are auto incrementing.

StanleyMasinde 2019-04-08 11:23:59
R_IT_Geek 2019-04-08 11:15:35
I have a many to many relationships for two user and product tables.

I called pivot table, a cart.

this is relationship code

return $this->belongsToMany(‘AppModelsProduct’, ‘carts’)->withPivot([‘uuid’, ‘user_ip’, ‘status’]);

When I run the following code, I get the following error.

$user->products()->attach([
‘product_id’ => $id,
‘uuid’ => Uuid::generate(4)->string,
‘user_ip’ => request()->ip(),
‘status’ => 1
]);

this is error:

SQLSTATE[HY000]: General error: 1364 Field ‘uuid’ doesn’t have a default value (SQL: insert into carts (product_id, user_id) values (3, 2), (2c443c9c-f724-420c-bfe8-6299d322e68d, 2), (192.168.1.20, 2), (1, 2))

From this there is a collumn not receiving values

R_IT_Geek 2019-04-08 11:26:59
StanleyMasinde 2019-04-08 11:23:59
From this there is a collumn not receiving values

OK, I used this on the relation:

->withPivot([‘uuid’, ‘user_ip’, ‘status’]);

StanleyMasinde 2019-04-08 11:27:22
R_IT_Geek 2019-04-08 11:26:59
OK, I used this on the relation:

->withPivot([‘uuid’, ‘user_ip’, ‘status’]);

Uuid is not receiving any value

R_IT_Geek 2019-04-08 11:30:32
I even set the uuid to the following, still giving it the same error.

‘uuid’ => ‘hiiii’,

|