how to find column in table using laravel
up vote
-1
down vote
favorite
how to find other column in table using laravel. By using the find($id)
i believe that this is for the id in the table. I want to find the lead_id
column in table. How will i able to do that? Here is my code below
$recent = RecentlyViewed::findLeadId($leadId);
$status = "Close/Converted";
$recent->flag_status = $status;
$recent->save();
in my model
class RecentlyViewed extends Model
{
public static function findLeadId($leadId)
{
return static::where('lead_id', $leadId)->first();
}
//
protected $fillable = [
'lead_id',
'client_id',
'status',
'first_name',
'last_name',
'date',
'flag_status',
];
}
it wont work to get the lead_id in my table recently viewed table. Any help is muchly appreciated. TIA
php laravel
add a comment |
up vote
-1
down vote
favorite
how to find other column in table using laravel. By using the find($id)
i believe that this is for the id in the table. I want to find the lead_id
column in table. How will i able to do that? Here is my code below
$recent = RecentlyViewed::findLeadId($leadId);
$status = "Close/Converted";
$recent->flag_status = $status;
$recent->save();
in my model
class RecentlyViewed extends Model
{
public static function findLeadId($leadId)
{
return static::where('lead_id', $leadId)->first();
}
//
protected $fillable = [
'lead_id',
'client_id',
'status',
'first_name',
'last_name',
'date',
'flag_status',
];
}
it wont work to get the lead_id in my table recently viewed table. Any help is muchly appreciated. TIA
php laravel
What does "it won't work" mean? Do you get an error of some sort?
– ceejayoz
Nov 22 at 17:40
1
changestatic
toself
– Afraz Ahmad
Nov 22 at 17:44
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
how to find other column in table using laravel. By using the find($id)
i believe that this is for the id in the table. I want to find the lead_id
column in table. How will i able to do that? Here is my code below
$recent = RecentlyViewed::findLeadId($leadId);
$status = "Close/Converted";
$recent->flag_status = $status;
$recent->save();
in my model
class RecentlyViewed extends Model
{
public static function findLeadId($leadId)
{
return static::where('lead_id', $leadId)->first();
}
//
protected $fillable = [
'lead_id',
'client_id',
'status',
'first_name',
'last_name',
'date',
'flag_status',
];
}
it wont work to get the lead_id in my table recently viewed table. Any help is muchly appreciated. TIA
php laravel
how to find other column in table using laravel. By using the find($id)
i believe that this is for the id in the table. I want to find the lead_id
column in table. How will i able to do that? Here is my code below
$recent = RecentlyViewed::findLeadId($leadId);
$status = "Close/Converted";
$recent->flag_status = $status;
$recent->save();
in my model
class RecentlyViewed extends Model
{
public static function findLeadId($leadId)
{
return static::where('lead_id', $leadId)->first();
}
//
protected $fillable = [
'lead_id',
'client_id',
'status',
'first_name',
'last_name',
'date',
'flag_status',
];
}
it wont work to get the lead_id in my table recently viewed table. Any help is muchly appreciated. TIA
php laravel
php laravel
asked Nov 22 at 17:31
PHP Dev
61112
61112
What does "it won't work" mean? Do you get an error of some sort?
– ceejayoz
Nov 22 at 17:40
1
changestatic
toself
– Afraz Ahmad
Nov 22 at 17:44
add a comment |
What does "it won't work" mean? Do you get an error of some sort?
– ceejayoz
Nov 22 at 17:40
1
changestatic
toself
– Afraz Ahmad
Nov 22 at 17:44
What does "it won't work" mean? Do you get an error of some sort?
– ceejayoz
Nov 22 at 17:40
What does "it won't work" mean? Do you get an error of some sort?
– ceejayoz
Nov 22 at 17:40
1
1
change
static
to self
– Afraz Ahmad
Nov 22 at 17:44
change
static
to self
– Afraz Ahmad
Nov 22 at 17:44
add a comment |
1 Answer
1
active
oldest
votes
up vote
-1
down vote
accepted
Add protected $primaryKey = "lead_id";
in model. If primaryKey significant other impacts. The do with Laravel query builder.
Don't forget to add use DB;
.
DB::table('RecentlyViewed')
->where('lead_id', $leadId)
->update(['flag_status' => "Close/Converted"]);
UsingDB::table
skips Eloquent, which may have significant side effects (especially if you use scopes, events etc.). Changing the primary key will also have major impacts, especially ifid
andlead_id
are used for different purposes.
– ceejayoz
Nov 22 at 19:28
so what is the best way for this?
– PHP Dev
Nov 23 at 5:59
@PHPDev You could answer my comments above, where I asked two questions - what does "it won't work" mean and what error do you get. You could also try Afraz Ahmad's suggestion.
– ceejayoz
Nov 23 at 17:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435897%2fhow-to-find-column-in-table-using-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-1
down vote
accepted
Add protected $primaryKey = "lead_id";
in model. If primaryKey significant other impacts. The do with Laravel query builder.
Don't forget to add use DB;
.
DB::table('RecentlyViewed')
->where('lead_id', $leadId)
->update(['flag_status' => "Close/Converted"]);
UsingDB::table
skips Eloquent, which may have significant side effects (especially if you use scopes, events etc.). Changing the primary key will also have major impacts, especially ifid
andlead_id
are used for different purposes.
– ceejayoz
Nov 22 at 19:28
so what is the best way for this?
– PHP Dev
Nov 23 at 5:59
@PHPDev You could answer my comments above, where I asked two questions - what does "it won't work" mean and what error do you get. You could also try Afraz Ahmad's suggestion.
– ceejayoz
Nov 23 at 17:03
add a comment |
up vote
-1
down vote
accepted
Add protected $primaryKey = "lead_id";
in model. If primaryKey significant other impacts. The do with Laravel query builder.
Don't forget to add use DB;
.
DB::table('RecentlyViewed')
->where('lead_id', $leadId)
->update(['flag_status' => "Close/Converted"]);
UsingDB::table
skips Eloquent, which may have significant side effects (especially if you use scopes, events etc.). Changing the primary key will also have major impacts, especially ifid
andlead_id
are used for different purposes.
– ceejayoz
Nov 22 at 19:28
so what is the best way for this?
– PHP Dev
Nov 23 at 5:59
@PHPDev You could answer my comments above, where I asked two questions - what does "it won't work" mean and what error do you get. You could also try Afraz Ahmad's suggestion.
– ceejayoz
Nov 23 at 17:03
add a comment |
up vote
-1
down vote
accepted
up vote
-1
down vote
accepted
Add protected $primaryKey = "lead_id";
in model. If primaryKey significant other impacts. The do with Laravel query builder.
Don't forget to add use DB;
.
DB::table('RecentlyViewed')
->where('lead_id', $leadId)
->update(['flag_status' => "Close/Converted"]);
Add protected $primaryKey = "lead_id";
in model. If primaryKey significant other impacts. The do with Laravel query builder.
Don't forget to add use DB;
.
DB::table('RecentlyViewed')
->where('lead_id', $leadId)
->update(['flag_status' => "Close/Converted"]);
answered Nov 22 at 17:45
Banujan Balendrakumar
477210
477210
UsingDB::table
skips Eloquent, which may have significant side effects (especially if you use scopes, events etc.). Changing the primary key will also have major impacts, especially ifid
andlead_id
are used for different purposes.
– ceejayoz
Nov 22 at 19:28
so what is the best way for this?
– PHP Dev
Nov 23 at 5:59
@PHPDev You could answer my comments above, where I asked two questions - what does "it won't work" mean and what error do you get. You could also try Afraz Ahmad's suggestion.
– ceejayoz
Nov 23 at 17:03
add a comment |
UsingDB::table
skips Eloquent, which may have significant side effects (especially if you use scopes, events etc.). Changing the primary key will also have major impacts, especially ifid
andlead_id
are used for different purposes.
– ceejayoz
Nov 22 at 19:28
so what is the best way for this?
– PHP Dev
Nov 23 at 5:59
@PHPDev You could answer my comments above, where I asked two questions - what does "it won't work" mean and what error do you get. You could also try Afraz Ahmad's suggestion.
– ceejayoz
Nov 23 at 17:03
Using
DB::table
skips Eloquent, which may have significant side effects (especially if you use scopes, events etc.). Changing the primary key will also have major impacts, especially if id
and lead_id
are used for different purposes.– ceejayoz
Nov 22 at 19:28
Using
DB::table
skips Eloquent, which may have significant side effects (especially if you use scopes, events etc.). Changing the primary key will also have major impacts, especially if id
and lead_id
are used for different purposes.– ceejayoz
Nov 22 at 19:28
so what is the best way for this?
– PHP Dev
Nov 23 at 5:59
so what is the best way for this?
– PHP Dev
Nov 23 at 5:59
@PHPDev You could answer my comments above, where I asked two questions - what does "it won't work" mean and what error do you get. You could also try Afraz Ahmad's suggestion.
– ceejayoz
Nov 23 at 17:03
@PHPDev You could answer my comments above, where I asked two questions - what does "it won't work" mean and what error do you get. You could also try Afraz Ahmad's suggestion.
– ceejayoz
Nov 23 at 17:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435897%2fhow-to-find-column-in-table-using-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does "it won't work" mean? Do you get an error of some sort?
– ceejayoz
Nov 22 at 17:40
1
change
static
toself
– Afraz Ahmad
Nov 22 at 17:44