Majeed

Majeed

Member Since 9 Months Ago

Feni

Jr. Software Engineer at Soft Tech Innovation Ltd. Dhaka

Experience Points 2,600
Experience Level 1

2,400 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 Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

04 Mar
1 month ago

Majeed 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');

        });
01 Mar
1 month ago

Majeed 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>
11 Feb
2 months ago

Majeed left a reply on 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

Majeed 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

10 Feb
2 months ago

Majeed left a reply on .htaccess File Doesn't Work Properly In Laravel

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

Majeed 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

29 Jan
2 months ago

Majeed left a reply on V-bind & V-model Binding Error In Vue.js

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

Majeed left a reply on V-bind & V-model Binding Error In Vue.js

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

Majeed left a reply on V-bind & V-model Binding Error In Vue.js

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

28 Jan
2 months ago

Majeed left a reply on 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"

Majeed left a reply on V-bind & V-model Binding Error In Vue.js

@REALRANDYALLEN - I have updated my question, please see

Majeed left a reply on V-bind & V-model Binding Error In Vue.js

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

Majeed left a reply on V-bind & V-model Binding Error In Vue.js

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

Majeed 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.

Here is my Code Sample:

<label>Name</label>
          <input name="name" class="form-control" v-bind:value="user.name" v-model="username"/>
 props:{

      user:{
        type:[Array,Object],
        required:true,
      },

    },
    data(){
      return{

       username:'',
       email:'',
       id:''
      }
    },

How can i solve this issue.

27 Jan
2 months ago

Majeed left a reply on 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.

26 Jan
2 months ago

Majeed left a reply on 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

Majeed 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

25 Jan
2 months ago

Majeed 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 Role pre-selected roles value based on userdata value..

23 Jan
3 months ago

Majeed left a reply on Vuejs Avoid Mutating A Prop Directly Warning

@MANELGAVALDA - but still doesn't show data in dropdownlist.

Majeed left a reply on Vuejs Avoid Mutating A Prop Directly Warning

@EDOC - update my question. please see..

Majeed left a reply on 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

Majeed left a reply on Vuejs Avoid Mutating A Prop Directly Warning

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

Majeed started a new conversation Vuejs Avoid Mutating A Prop Directly Warning

this my props value.

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

and this is my dropdownlist.

 <select multiple v-model="roles">
             <option v-for="role in roles">{{role.name}}</option>
           </select>

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 ?

08 Jan
3 months ago

Majeed left a reply on 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...

Majeed 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? **

06 Jan
3 months ago

Majeed left a reply on 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
05 Jan
3 months ago

Majeed left a reply on 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');

Majeed 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')
23 Sep
7 months ago

Majeed left a reply on 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,
});

Majeed 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.

08 Aug
8 months ago

Majeed 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"
    },

24 Jul
9 months ago

Majeed left a reply on How To Test Personal Access Token Using Guzzlehttp In Laravel

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

23 Jul
9 months ago

Majeed 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');

22 Jul
9 months ago

Majeed left a reply on 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

Majeed 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 ??

21 Jul
9 months ago

Majeed left a reply on 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.

20 Jul
9 months ago

Majeed started a new conversation How To Add Bearer Access Token In Request Header From Controller In Laravel

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]');
});

19 Jul
9 months ago

Majeed 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); 
    } 

    
}

07 Jul
9 months ago

Majeed left a reply on Laravel Middleware Doesn't Work Properly.

what about for this way...

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

06 Jul
9 months ago

Majeed left a reply on Laravel Middleware Doesn't Work Properly.

I update my question please see now. @Cronix

Majeed 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.

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

Here, is my middleware.

    {
      
        $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);
    }```
01 Jul
9 months ago

Majeed left a reply on How Do I Use Javascript/jquery Plugins In Laravel?

Please import js file this way.

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

28 Jun
9 months ago

Majeed left a reply on How To Drop Table ?

After that you have run this command.

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

Majeed left a reply on How To Drop Table ?

Run this Command $ php artisan make:migration drop_user_table

27 Jun
9 months ago

Majeed left a reply on 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();
        }

        return $next($request);
    }
}

Majeed left a reply on 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. **

26 Jun
9 months ago

Majeed left a reply on How To Filter Intermediate Table

You may also use the `sync' method.

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