Majeed

Majeed

Jr. Software Engineer at Soft Tech Innovation Ltd. Dhaka

Member Since 1 Year Ago

Feni

Experience Points
2,700
Total
Experience

2,300 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
8
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
2,700 XP
Oct
09
1 week ago
Activity icon

Started a new Conversation How To Write Regex In Laravel

I want write a regex for abc-def-ghi this type of string. a string have must - sign if it'll not available then show a validation message in Laravel

Jul
18
3 months ago
Activity icon

Started a new Conversation Route Facade Vs $router Variable

In Laravel we use the Route facade for declare a route. for example:

Route::get('/',function(){

   return view('welcome');

});

in the other hand, In Lumen we use the $router instead of Route facade. for example:

$router->get('/',function(){

   return $router->app->version();

});

my question is where this $router variable is declare or bind in lumen. can i use this in Laravel Project ?

Mar
04
7 months ago
Activity icon

Started a new Conversation PDOException::("SQLSTATE[HY000]: General Error: 1215 Cannot Add Foreign Key Constraint")

Hi, Here i'm working on Laravel5.8 i'm using foreign_key constraint in my migrations. but when i going to migrate it's show an error.

PDOException::("SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint")

** but the same code run properly in laravel5.7 version**

Here is a change between laravel5.8 which is bigIncrements .

Here is my code sample.

Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->softDeletes();
            $table->timestamps();
        });
  Schema::create('roles', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('slug')->unique();
            $table->text('description');
            $table->softDeletes();
            $table->timestamps();
        });
Schema::create('role_user', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('role_id')->unsigned();
            $table->integer('user_id')->unsigned();

            /** database side relation constraint */
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

        });
Mar
01
7 months ago
Activity icon

Started a new Conversation Laravel Htaccess Doesn't Work On Live Server

I have upload a project on live server and remove public folder from url. now when i want to access my project it's only the welcome page, when i try to access login or register it's show

404 Sorry, the page you are looking for could not be found.

Here, i'm share my /.htaccess file

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On
    

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Feb
11
8 months ago
Activity icon

Replied to Style Doesn't Load After Remove Public From Url In Laravel

@BILLRIESS - No, i just remove the public from the url but I want redirect to the public folder every request from the root .htaccess file

Activity icon

Started a new Conversation Style Doesn't Load After Remove Public From Url In Laravel

I'm add a .htaccess file in my project root. after add this .htaccess file i can remove the public from my url but style and js file doesn't load now.

Here is my htaccess file

<IfModule mod_rewrite.c>

<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On
# Prevent direct access to the "public" folder - redirect to root
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /public/
RewriteRule ^public/(.*) / [R=302,L]

# Redirect Trailing Slashes If Not A Folder...
# - but look for the file in the "public" folder
# (ensure we are not already in the "public" folder)
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{DOCUMENT_ROOT}/public/ !-d
RewriteRule ^(.*)/$ / [R=302,L]

# Rewrite "everything" to the "public" subdirectory if not already
# This ignores existing files/dirs in the document root
RewriteCond %{REQUEST_URI} ^/(.*)
RewriteRule !^public/ public/%1

# Handle Front Controller... (as before)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php [L]
</IfModule>

How could i load css and js from .htaccess file

Feb
10
8 months ago
Activity icon

Replied to .htaccess File Doesn't Work Properly In Laravel

@DOUGLASAKULA - yes, i'm using apache2. but i'm not configure any virtual host

Activity icon

Started a new Conversation .htaccess File Doesn't Work Properly In Laravel

I'm working on a Laravel project. I'm Removing "/public" from URL but it's only work on welcome page, other page like /login,/register is doesn't work properly. it's shows an error.

The requested URL /GME/login was not found on this server.

Apache/2.4.18 (Ubuntu) Server at localhost Port 80

but when I use public/index.php in URL it's working.

http://localhost/GME/public/index.php/login

Here, is my root .htaccess file code.

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public/
    RewriteRule ^(.*)$ public/ [L] #relative substitution
    RewriteRule ^ index.php
</IfModule>

and here is my /public/.htaccess file code.

    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

note: i'm using linux elementary OS loki version

Jan
29
8 months ago
Activity icon

Replied to V-bind & V-model Binding Error In Vue.js

@REALRANDYALLEN - it's working like charm, Thank you, for your co-operation...

Activity icon

Replied to V-bind & V-model Binding Error In Vue.js

I Can access the value when i use v-model=user.name

Activity icon

Replied to V-bind & V-model Binding Error In Vue.js

no, my child component is a modal that's occur this problem

Jan
28
8 months ago
Activity icon

Replied to V-bind & V-model Binding Error In Vue.js

@REALRANDYALLEN - It's show a warning [Vue warn]: Error in mounted hook: "ReferenceError: user is not defined"

Activity icon

Replied to V-bind & V-model Binding Error In Vue.js

@REALRANDYALLEN - I have updated my question, please see

Activity icon

Replied to V-bind & V-model Binding Error In Vue.js

@REALRANDYALLEN - i've checked it has value...

Activity icon

Replied to V-bind & V-model Binding Error In Vue.js

@REALRANDYALLEN - it's shows empty value in input field.

Activity icon

Started a new Conversation V-bind & V-model Binding Error In Vue.js

I've use v-bind and v-model in my form input field. but when i run npm run dev command it's show the: v-bind:value="user.name" conflicts with v-model on the same element because the latter already expands to a value binding internally error.

in v-bind i'm bind my props value and in v-model use a variable.

This is my Child Component.

<transition name="modal">
 <div class="modal modal-mask" style="display: block">
  <div class="modal-dialog modal-overflow" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">
          {{modalTitle}}
        </h4>
        <button type="button" class="close" aria-label="Close" @click="close">
        <span aria-hidden="true">&times;</span>
      </button>
      </div>
      
      <div class="modal-body">
        <form>
        
         <div class="form-group">
          <label>Name</label>
          <input name="name" class="form-control"  v-model="username"/>
         </div>
         <div class="form-group">
          <label>E-mail</label>
          <input name="email" class="form-control" v-bind:value="user.email"/>
         </div>
         <div class="form-group">
          <label>Role</label>
          {{userRoles}}
          <select multiple v-model="userRoles" class="form-control"  >
                {{datauser}}
               <option v-for="(role,index) in roles" v-bind:value="role.id">{{role.name}}</option>

           </select>
         </div>
          <div class="form-group">
          <label>Permissions</label>
          <select multiple class="form-control" v-model="mutablePermissions" >
           <option v-for="(permission,index) in permit"  v-bind:value="permission.id">{{permission.name}}</option> 
          </select>
         </div>
        
        </form>
      </div>
      
      <div class="modal-footer">
       <button type="button" class="btn btn-primary" @click="updateUser">Save</button>
       <button type="button" class="btn btn-danger" @click="close">Close</button>
      </div>
    </div>
  </div>
</div>
</transition> 
<!--end modal-->
</template>
<script>
export default {
  // props:[
  //   'modalTitle',
  //   'user',
  //   'roles'
  // ],

    props:{
      modalTitle:{
        type:String,
        required:true,
      },
      user:{
        type:[Array,Object],
        required:true,
      },
      mutableRoles:{
        type:[Array,Object],
        required:true,
      },
      roles:{
        type:[Array,Object],
        required:true,
      },
      permit:{
        type:[Array,Object],
        required:true,
      }
    },
    data(){
      return{
       
       mutablePermissions:[],
       userRoles:[],
       userPermissions:[],
       username:this.user.name,
       email:'',
       id:''
      }
    },
    created() {
     
    },
   
    methods: {
        close:function(){
            this.$emit('closeModal');
          
        },
        updateUser:function(){
          return this.username
        }
        
    },
    computed: {
        datauser:function(){
          this.userRoles=this.mutableRoles
        },
        
    },
    watch: {    
    },
    mounted() {
     
    },
}
</script>

pass props value from Parent component.

  <update-modal v-show="ismodalOn" @closeModal="shutModal" :modalTitle="title" :mutable-roles="userdata" :user="user" :roles="roles" :permit="permissions"/>

How can i solve this issue.

Jan
27
8 months ago
Activity icon

Replied to How To Pass Props Array Into A Child Component Array In Vue

@REALRANDYALLEN - that's working, but when i select new value it's shows a warning: [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders.

Jan
26
8 months ago
Activity icon

Replied to How To Pass Props Array Into A Child Component Array In Vue

@REALRANDYALLEN - no, i want to copy into another array. just like this:

this.mutableRoles=this.userdata
Activity icon

Started a new Conversation How To Pass Props Array Into A Child Component Array In Vue

I'm try to pass a parent props array in my child component array. my child component is a modal Here,is my props value

props:{
 userdata:{
        type:[Array,Object],
        required:true,
      },
}

and my child component array

data(){
      return{
       mutableRoles:[],    
      }

i want to pass my userdata array into my mutableRoles array

Jan
25
8 months ago
Activity icon

Started a new Conversation How To Set Pre-selected Value In Vue Js Dropdownlist.

I want to set selected value on dropdownlist in Vue. Here is my code:

  <label>Role</label>
          <select multiple v-model="mutableRoles" class="form-control">
             <option v-for="(role,index) in roles"  v-bind:value="index">{{role.name}}</option>
           </select>

 props:{
      userdata:{
        type:[Array,Object],
        required:true,
      },
      roles:{
        type:[Array,Object],
        required:true,
      },
    },
    data(){
      return{
       mutableRoles:[],
    
      }
    },

i want to pre-selected roles value based on userdata value..

Jan
23
8 months ago
Activity icon

Replied to Vuejs Avoid Mutating A Prop Directly Warning

@EDOC - update my question. please see..

Activity icon

Replied to Vuejs Avoid Mutating A Prop Directly Warning

@MANELGAVALDA - console.log(this.roles) it's shows output, but mutableRoles: this.roles this is show empty array

Activity icon

Replied to Vuejs Avoid Mutating A Prop Directly Warning

@MANELGAVALDA - It's show empty. mutableRoles is shows an empty array

Activity icon

Started a new Conversation Vuejs Avoid Mutating A Prop Directly Warning

this my props value.

<template>
      <!-- Modal -->
 <transition name="modal">
 <div class="modal modal-mask" style="display: block">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">
          {{modalTitle}}
        </h4>
        <button type="button" class="close" aria-label="Close" @click="close">
        <span aria-hidden="true">&times;</span>
      </button>
      </div>
      
      <div class="modal-body">
        <form>
          {{roles}}
         <div class="form-group">
          <label>Name</label>
          <input name="name" class="form-control"/>
         </div>
         <div class="form-group">
          <label>E-mail</label>
          <input name="email" class="form-control"/>
         </div>
         <div class="form-group">
          <label>Role</label>
          <select multiple v-model="mutableRoles">
             <option v-for="role in mutableRoles">{{role.name}}</option>
           </select>
         </div>
          <div class="form-group">
          <label>Permissions</label>
          <select multiple class="form-control">
           <option>ABC</option> 
          </select>
         </div>
        
        </form>
      </div>
      
      <div class="modal-footer">
       <button type="button" class="btn btn-primary">Save</button>
       <button type="button" class="btn btn-danger" @click="close">Close</button>
      </div>
    </div>
  </div>
</div>
</transition> 
</template>
<script>
export default {
 

     props:{
       modalTitle:{
         type:String,
         required:true,
       },
       user:{
         type:[Array,Object],
         required:true,
       },
       roles:{
         type:[Array,Object],
         required:true,
       },
       permit:{
         type:[Array,Object],
         required:true,
       }
     },
    data(){
      return{
        mutableRoles: this.roles
      }
    },
   
    methods: {
        close:function(){
            this.$emit('closeModal');
        },
        
    },
}
</script>

I want to show this props value in dropdownlist this way. but it's show Avoid mutating a prop directly warn . what I've done wrong ?

Jan
08
9 months ago
Activity icon

Replied to Convert A Collection Or Object To An Array

@MIKEMACDOWELL - @mikemacdowell thanks. it's working. but there is raise a duplicate value issue like:-

[
{
id: 1,
name: "Create",
slug: "Create",
description: "This is simple Create Permission",
created_at: "2018-12-17 18:54:07",
updated_at: "2018-12-17 18:54:07",
deleted_at: null,
pivot: {
role_id: 1,
permission_id: 1,
},
},

{
id: 3,
name: "Update",
slug: "Update",
description: "This is Simple Update Permission",
created_at: "2018-12-17 18:54:07",
updated_at: "2018-12-17 18:54:07",
deleted_at: null,
pivot: {
role_id: 1,
permission_id: 3,
},
},

{
id: 3,
name: "Update",
slug: "Update",
description: "This is Simple Update Permission",
created_at: "2018-12-17 18:54:07",
updated_at: "2018-12-17 18:54:07",
deleted_at: null,
pivot: {
role_id: 2,
permission_id: 3,
},
},
]

How can i made this unique...

Activity icon

Started a new Conversation Convert A Collection Or Object To An Array

This is my query:

$data=Auth::user()->roles()->with('permissions')->get()->pluck('permissions');
 return $data;

The output of the query is as following:

     [
      [
       {
        id: 2,
        name: "Read",
        slug: "Read",
        description: "This is Simple Read Permission",
         pivot: {
         role_id: 2,
         permission_id: 2,
         },
        },
       {
        id: 3,
        name: "Update",
        slug: "Update",
        description: "This is Simple Update Permission",

        pivot: {
         role_id: 2,
         permission_id: 3,
        },
       },
      ]
     ]

**How can I convert this collection in to an array? **

Jan
06
9 months ago
Activity icon

Replied to HOW To Use Where Clause In Egar Loading Eloquent Query In Laravel

@SNAPEY - it's refers an error

** Property [permissions] does not exist on this collection **

Auth::user()->roles()->with(['permissions'=>function($q){$q->where('permission_id','=',3);}])->get()->permissions
Jan
05
9 months ago
Activity icon

Replied to HOW To Use Where Clause In Egar Loading Eloquent Query In Laravel

@JAHELLER -

Auth::user()->roles()->with(['permissions'=>function($q){$q->where('permissions.id','=',3);}])->get()->pluck('permissions'); 

I'm try this way but it's return empty an array.

Activity icon

Started a new Conversation HOW To Use Where Clause In Egar Loading Eloquent Query In Laravel

I'm working on ACL system. during working on system I've face a challenge. Here is my query , How can i use where clause in this query...

$this->roles()->with('permissions')->get()->pluck('permissions')
Sep
23
1 year ago
Activity icon

Replied to How To Define Parent And Child Component In Vue.js

I have seen an example, where declare child component using <router-view></router-view> inside App.vue component. and import all vue component in app.js file

Here, is the code sample.

import Vue from 'vue'
import VueRouter from 'vue-router'

//vue instance use the vueRouter.
Vue.use(VueRouter)

//component listed here
import App from './views/App'
import Home from './views/Home'
const router = new VueRouter({
    mode: 'history',
    routes: [
        {
            path: '/',
            name: 'home',
            component: Home
        },
   
    ],
})

const app = new Vue({
    el: '#app',
    components: { App },
    router,
});

Activity icon

Started a new Conversation How To Define Parent And Child Component In Vue.js

I'm working with Vue component . I've created two simple component one is App.vue another is Home.vue . now i want to define App.vue as a parent component and Home.vue as child component.

Aug
08
1 year ago
Activity icon

Started a new Conversation How To Upgrade A Laravel Library From 5.5 To 5.6 Laravel Version.

I want to upgrade my Laravel Library from laravel 5.5 to 5.6. Here is my library composer.json file.

 "require": {
        "php": ">=5.5.9",
        "guzzlehttp/guzzle": "^6.2",
        "laravelcollective/html": "^5.4.0"
    },

Jul
24
1 year ago
Activity icon

Replied to How To Test Personal Access Token Using Guzzlehttp In Laravel

It's send null, there are any other way to test Personal access token.

Jul
23
1 year ago
Activity icon

Started a new Conversation How To Test Personal Access Token Using Guzzlehttp In Laravel

I'm working on Laravel Passport. I have created a personal access token. Now, I want to test it using guzzlehttp Client. How can i do this. I'm try this way it's not working. my routes/web.php

Route::get('/callback', function (Request $request) {
         $response = (new GuzzleHttp\Client)->post('http://passportauth.test/oauth/token', [
                'form_params' => [
                    'grant_type' => 'authorization_code',
                    'client_id' => 1, // Laravel Personal Access Client ID
                    'client_secret' => 'zeFLAy76pZdCuHuKXjPCEgY0MMhnkADYbIRKzZQz', // Replace with client secret
                    'redirect_uri' => 'http://passportauth.test/callback',
                    'code' => $request->code,
                ]
            ]);

            session()->put('token', json_decode((string) $response->getBody(), true));

            return redirect('/test');
             //return json_decode((string) $response->getBody(), true);
        });

Route::get('/test', function () {
       $response = (new GuzzleHttp\Client)->get('http://passportauth.test/api/test', [
           'headers' => [
               'Authorization' => 'Bearer '.session()->get('token.access_token')
           ]
       ]);

       return json_decode((string) $response->getBody(), true);
   });

my routes\api.php


Route::get('/test',function(){
    return 'This is an API Endpoints';
})->middleware('auth:api');

Jul
22
1 year ago
Activity icon

Replied to How To Set Bearer Access_token In Request Header From Laravel Back-end

I want this because when I send a request from browser to an API endpoints. where Postman isn't present. that situation how can i handle this Bearer Token. Please you have any solutions that's kind of situation suggest me. I'm new working with API. Thank You @Nee

Activity icon

Started a new Conversation How To Set Bearer Access_token In Request Header From Laravel Back-end

I'm try this way to add Bearer access_token in every request header from my middleware.

 public function handle($request, Closure $next)
    {
        $request->header('Authorization',"Bearer ".$request->bearerToken());

        return $next($request);
    }

But it's not working. Is there any way ??

Jul
21
1 year ago
Activity icon

Replied to How To Add Bearer Token In Request Header Using Laravel Controller Or Middleware

i want to do set bearer in request from backend controller, not enter manually in postman.

Jul
20
1 year ago
Activity icon

Started a new Conversation How To Add Bearer Token In Request Header Using Laravel Controller Or Middleware

I'm working on Laravel API Authentication. for every request I'm added the Bearer Token in request Header. But I want to do this from my Backend controller or middleware. i'm tried this way But it's not working.

My Middleware.

 public function handle($request, Closure $next)
    {
        $request->header('Authorization',"Bearer ".$request->bearerToken());

        return $next($request);
    }

My Kernal File.

protected $middlewareGroups = [

        'Header'  =>[
            \App\Http\Middleware\HeaderMiddleware::class
        ],
    ];

and my Route

Route::group(['middleware' => ['auth:api','Header']], function(){
Route::post('details', 'API\[email protected]');
Route::get('test','API\[email protected]');
});

Jul
19
1 year ago
Activity icon

Started a new Conversation How To Add Bearer Access Token To A Request Header From Controller In Laravel

I'm working on Laravel Passport to make a API Authentication system. After successful login i'm getting an access_token and for every request i need to add the Bearer access_token in request header. I want to add this Bearer access_token in request header from my controller.

Here, Is my Controller

class PassportController extends Controller
{

   public $successStatus = 200;

    public function login()
    { 
        if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){ 
            $user = Auth::user(); 
            $success['token'] =  $user->createToken('MyApp')-> accessToken; 
            return response()->json(['success' => $success], $this-> successStatus); 
        } 
        else{ 
            return response()->json(['error'=>'Unauthorised'], 401); 
        } 
    }

    public function register(Request $request) 
    { 
        $validator = Validator::make($request->all(), [ 
            'name' => 'required', 
            'email' => 'required|email', 
            'password' => 'required', 
            'c_password' => 'required|same:password', 
        ]);
        if ($validator->fails()) { 
                    return response()->json(['error'=>$validator->errors()], 401);            
                }
        // $input = $request->all(); 
        //         $input['password'] = bcrypt($input['password']); 
        //         $user = User::create($input); 
                $user=new User();
                $user->name=$request->name;
                $user->email=$request->email;
                $user->password=bcrypt($request->password);
                $user->save();
                $success['token'] =  $user->createToken('MyApp')-> accessToken; 
                $success['name'] =  $user->name;
        return response()->json(['success'=>$success], $this-> successStatus); 
    }

    public function details(Request $request) 
    { 
        $user = Auth::user(); 
        
       //  'headers' => [
       //  'Accept' => 'application/json',
       //  'Authorization' => 'Bearer '.$accessToken,
       // ],
        $token=$request->post('/oauth/token', [
            'content-type' => 'application/json',
            'Accept' => 'application/json',
            'Authorization' => 'Bearer '.'mahgf1234567890',
        ]);
        //$token=$request->header('Authorization');


        return response()->json(['success' => $user,'token' => $token], $this-> successStatus); 
    } 

    
}

Jul
07
1 year ago
Activity icon

Replied to Laravel Middleware Doesn't Work Properly.

what about for this way... @cronix

$this->middleware('HasRole:User|Admin|Author')->except(['userEdit','roleEdit','permissionEdit','userUpdate']);
Jul
06
1 year ago
Activity icon

Replied to Laravel Middleware Doesn't Work Properly.

I update my question please see now. @Cronix

Activity icon

Started a new Conversation Laravel Middleware Doesn't Work Properly.

I have a role middleware. when i pass to role from my controller as a string it's work properly but when pass as an array it's not working. This way middleware work properly.

$this->middleware('HasRole:User|Admin|Author')->except(['userEdit','roleEdit','permissionEdit','userUpdate']);

But when I change like this, it's not working.

    $this->middleware('HasRole:User,Admin,Author')->except(['userEdit','roleEdit','permissionEdit','userUpdate']);

Here, is my middleware.

public function handle($request, Closure $next, ...$role)
    {
      
        $roles=is_array($role)? $role: explode('|', $role);
        //dd($roles);

        if($request->user()===null)
        {
            return response('Insufficient Access',401);
        }

        if($request->user()->hasAnyRole($roles) || !$roles)
        {
             return $next($request);
        }
          return response('Insufficient Permission',401);
        //return $next($request);
    }
Jul
01
1 year ago
Activity icon

Replied to How Do I Use Javascript/jquery Plugins In Laravel?

Please import js file this way.

{{asset("js/demo.js")}}

Jun
28
1 year ago
Activity icon

Replied to How To Drop Table ?

After that you have run this command.

php artisan migrate --path=/database/migrations/role_user/

Activity icon

Replied to How To Drop Table ?

Run this Command $ php artisan make:migration drop_user_table

Jun
27
1 year ago
Activity icon

Replied to Redirect To The Last Action After Login

Try This way. Hope it will help

class RedirectIfAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return back(); 
     //or return redirect()->back(); 
        }

        return $next($request);
    }
}
Activity icon

Replied to Many To Many Showing Only Few Rows

You can try this way.

 public function tags(){
        return $this->belongsToMany('App\Tag');
    }
 public function nodes(){
        return $this->belongsToMany('App\Node');
    }

fetch data from pivot or intermediate table.

$node=Node::with('tags')->get();
return $node;

**It will show the Json Data. **

Jun
26
1 year ago
Activity icon

Replied to How To Filter Intermediate Table

You may also use the sync method.

php $cart->tags()->sync([$item->id], false);