php - Laravel: Cannot get hasOne foreign key data from users table inside a controller -


i want retrieve data foreign key using db::table query inside controller i'm getting error says: property [assigned_to] not exist on collection instance. made 1 many , inverse relationship between users , tables.

$accesses = db::table('accesses')                 ->select(array('id', 'fullname','emp_id','shift','state','resolved_at', 'closed_at','assigned_to'))                 ->where('state','=','assigned');  $all = db::table('reports')                 ->select(array('id', 'fullname','emp_id','shift','state','resolved_at', 'closed_at','assigned_to'))                 ->union($accesses)                 ->where('state', '=', 'assigned')                 ->get();  $open_tickets = charts::database($all, 'bar', 'highcharts')                 ->title("open tickets (assigned)")                 ->elementlabel("total assigned tickets")                 ->dimensions(1000, 500)                 ->responsive(false)                 ->groupby('assigned_to')                 ->labels($all->assigned_to->name);   //users migration schema::create('users', function (blueprint $table) {         $table->increments('id');         $table->string('emp_id');         $table->string('shift');         $table->string('name');         $table->string('email')->unique();         $table->string('contact')->nullable();         $table->string('password');         $table->string('role')->default('admin');         $table->remembertoken();         $table->timestamps();     });     //reports migration schema::create('reports', function (blueprint $table) {         $table->increments('id');         $table->integer('user_id')->nullable();         $table->string('fullname');         $table->string('emp_id');         $table->string('shift');         $table->longtext('report');         $table->string('status')->default('pending'); //pending, approved         $table->string('state')->default('open'); //open, assigned, resolved, closed         $table->date('resolved_at')->nullable();         $table->date('closed_at')->nullable();         $table->integer('assigned_to')->nullable();         $table->longtext('action')->nullable();         $table->timestamps();     });      //accesses migration| schema::create('accesses', function (blueprint $table) {         $table->increments('id');         $table->integer('user_id')->nullable();         $table->string('fullname');         $table->string('emp_id');         $table->string('shift');         $table->string('request');         $table->longtext('note')->nullable();         $table->string('status')->default('pending'); //pending, approved         $table->string('state')->default('open'); //open, assigned, resolved, closed         $table->date('resolved_at')->nullable();         $table->date('closed_at')->nullable();         $table->integer('assigned_to')->nullable();         $table->longtext('action')->nullable();         $table->timestamps();     }); 

this desired results

this migrations table


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -