Karthik
Karthik

Reputation: 5759

Illegal offset type in isset or empty Laravel

I use the following query to get Project Id and Id of Particular Table in Laravel.

$projectlist = Projects::Where('customer',$request->input('client_name'))->pluck(DB::raw("CONCAT('project_prefix','project_nos') AS projectid"),"id");

I got following Error.

message Illegal offset type in isset or empty
exception   ErrorException
file    /var/www/msstone/vendor/laravel/framework/src/Illuminate/Support/Str.php

Project Model

namespace App;

use Illuminate\Database\Eloquent\Model;

class Projects extends Model
{
    protected $guarded = ['id'];

    protected $table = 'projects';

}

Upvotes: 5

Views: 7587

Answers (1)

Dhananjay Kyada
Dhananjay Kyada

Reputation: 1036

Try by changing the eloquent query from:

$projectlist=Projects::Where('customer',$request->input('client_name'))->pluck(DB::raw("CONCAT('project_prefix','project_nos') AS projectid"),"id");

to

$projectlist = Projects::select(DB::raw("CONCAT(project_prefix,project_nos) AS projectid"),'id')->where('customer',$request->input('client_name'))->pluck("projectid","id");

Upvotes: 2

Related Questions