Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9124281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:32:13+00:00 2026-06-17T06:32:13+00:00

I am trying to build a menu according to user roles using many to

  • 0

I am trying to build a menu according to user roles using many to many relationship. laravel is my first php framework and i am facing this issue

Unhandled Exception

Message:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_role.created_at' in 'field list'

SQL: SELECT `roles`.*, `user_role`.`id` AS `pivot_id`, `user_role`.`created_at` AS `pivot_created_at`, `user_role`.`updated_at` AS `pivot_updated_at`, `user_role`.`user_id` AS `pivot_user_id`, `user_role`.`role_id` AS `pivot_role_id` FROM `roles` INNER JOIN `user_role` ON `roles`.`id` = `user_role`.`role_id` WHERE `user_role`.`user_id` = ?

Bindings: array (
  0 => 1,
)

user migration:

<?php
class Users {

public function up()
{
    Schema::create('users', function($table){
        $table->engine = 'InnoDB';
        $table->increments('id');
        $table->string('username', 128);
        $table->string('password', 128);
        $table->string('firstname', 128);
        $table->string('lastname', 128);
        $table->date('dob');
        $table->string('phone')->nullable();
        $table->text('image')->nullable();
        $table->timestamps();
    });

    DB::table('users')->insert(array(
        'username' => 'admin',
        'password' => Hash::make('admin'),
        'firstname' => 'asdf',
        'lastname' => 'zxcv',
        'dob' => '1990-02-23',
        'phone' => '935735367'
    ));

}

function down()
{
    Schema::drop('users');
}

}

roles migration:

<?php

class Role {

    public function up()
    {
        Schema::create('roles', function($table){
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string('lable', 60);
            $table->string('url', 128)->default("#");
            $table->integer('parent')->default("0");
            $table->integer('level')->default("0");
            $table->integer('sort')->default("0");
            $table->integer('published')->default("0");
        });

    }

    public function down()
    {
        Schema::drop('roles');
    }

}

role_user

<?php

class Access {

    public function up()
    {
        Schema::create('role_user', function($table){
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->integer('role_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('role_id')->references('id')->on('roles');
        });


    }

    public function down()
    {
        Schema::drop('role_user');
    }

}

user model:

<?php 
class User extends Basemodel{
    public static $table = 'users';
    public static $timestamps = true;
    public static $rules = array(
        'username' => 'required|min:3|alpha',
        'password' => 'required|min:3|alpha'
    );

    public function roles()
    {
        return $this->has_many_and_belongs_to('Role');
    }

    public static function menu(){
        $roles = User::find(1)->roles()->get();
        return $roles;
    }
}

Role Model

<?php 
class Role extends Eloquent{
    public static $table = 'roles';

}

Controller:

<?php

class Home_Controller extends Base_Controller {
public $restful= true;

public function get_index()
{
    return View::make('home.index')
        ->with('title','App Index')
        ->with('menu',User::menu());
}

can someone guide me on what to do ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:32:15+00:00Added an answer on June 17, 2026 at 6:32 am

    It looks like, at first glance, the timestamp columns are missing in the user_role table.
    If you add the two columns; created_at and updated_at to the table and set them to datetime it should fix it up for you!

    Also by the looks of things, your roles table doesn’t have these timestamps described above either. You should either add these or set a public static variable in the Role model to state that they aren’t there. You can do this by writing public static $timestamps = false

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a menu using CSS.This is what i have done
I'm trying to build a menu using a UItableView with Custom cells which have
I am trying to build a simple nested html menu using HAML and am
I am trying to build a navigation menu using nested lists, however whenever I
I trying to build my own multi dropdown menu, and i encounter this problem
Okay, I'm thoroughly stumped on this one. I'm trying to build a menu of
Im trying to build my dropdown menu using the plugin Chosen for Multiple Select
I'm trying to build a tab menu system using a background image for the
I'm trying to build a dynamic menu (with sub menus) in Php and MySql.
I'm trying to build a horizontal list based menu. In this menu, the two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.