uri segment laravel not working for string
up vote
0
down vote
favorite
In my database, primary key has string and number likes
ex : BRG2289182
My Controller
public function edit(BarangModel $barang)
return view('fbarangs.edit',compact('barang'));
My Model
class BarangModel extends Model
protected $fillable = [
'barang_kode',
'barang_nama',
'barang_jenis',
'barang_hbeli',
'barang_hjual',
'barang_stok',
];
protected $table = 'barangs';
protected $primaryKey = 'barang_kode';
My routes
Route::resource('barangs','BarangController');
my link
<a class="btn btn-primary"
href=" route('barangs.edit',$barang->barang_kode) ">
<i class="fa fa-pencil"></i>
</a>
I want to do routing for view, edit, delete. in my database, there is one primary key field that uses a mixture of letters and numbers.
and the problem is when I use it for routing why can't it?
but when I change the primary key data to a number, the result is successful. can anyone help me?
answer :
add this code on my model
public $incrementing = false
laravel laravel-5
add a comment |
up vote
0
down vote
favorite
In my database, primary key has string and number likes
ex : BRG2289182
My Controller
public function edit(BarangModel $barang)
return view('fbarangs.edit',compact('barang'));
My Model
class BarangModel extends Model
protected $fillable = [
'barang_kode',
'barang_nama',
'barang_jenis',
'barang_hbeli',
'barang_hjual',
'barang_stok',
];
protected $table = 'barangs';
protected $primaryKey = 'barang_kode';
My routes
Route::resource('barangs','BarangController');
my link
<a class="btn btn-primary"
href=" route('barangs.edit',$barang->barang_kode) ">
<i class="fa fa-pencil"></i>
</a>
I want to do routing for view, edit, delete. in my database, there is one primary key field that uses a mixture of letters and numbers.
and the problem is when I use it for routing why can't it?
but when I change the primary key data to a number, the result is successful. can anyone help me?
answer :
add this code on my model
public $incrementing = false
laravel laravel-5
2
Have you tried settingprotected $incrementing = falseon the model?
– Travis Britz
20 hours ago
it seems that I haven't used the code yet.
– AdityaDS
20 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In my database, primary key has string and number likes
ex : BRG2289182
My Controller
public function edit(BarangModel $barang)
return view('fbarangs.edit',compact('barang'));
My Model
class BarangModel extends Model
protected $fillable = [
'barang_kode',
'barang_nama',
'barang_jenis',
'barang_hbeli',
'barang_hjual',
'barang_stok',
];
protected $table = 'barangs';
protected $primaryKey = 'barang_kode';
My routes
Route::resource('barangs','BarangController');
my link
<a class="btn btn-primary"
href=" route('barangs.edit',$barang->barang_kode) ">
<i class="fa fa-pencil"></i>
</a>
I want to do routing for view, edit, delete. in my database, there is one primary key field that uses a mixture of letters and numbers.
and the problem is when I use it for routing why can't it?
but when I change the primary key data to a number, the result is successful. can anyone help me?
answer :
add this code on my model
public $incrementing = false
laravel laravel-5
In my database, primary key has string and number likes
ex : BRG2289182
My Controller
public function edit(BarangModel $barang)
return view('fbarangs.edit',compact('barang'));
My Model
class BarangModel extends Model
protected $fillable = [
'barang_kode',
'barang_nama',
'barang_jenis',
'barang_hbeli',
'barang_hjual',
'barang_stok',
];
protected $table = 'barangs';
protected $primaryKey = 'barang_kode';
My routes
Route::resource('barangs','BarangController');
my link
<a class="btn btn-primary"
href=" route('barangs.edit',$barang->barang_kode) ">
<i class="fa fa-pencil"></i>
</a>
I want to do routing for view, edit, delete. in my database, there is one primary key field that uses a mixture of letters and numbers.
and the problem is when I use it for routing why can't it?
but when I change the primary key data to a number, the result is successful. can anyone help me?
answer :
add this code on my model
public $incrementing = false
laravel laravel-5
laravel laravel-5
edited 19 hours ago
asked 20 hours ago
AdityaDS
177113
177113
2
Have you tried settingprotected $incrementing = falseon the model?
– Travis Britz
20 hours ago
it seems that I haven't used the code yet.
– AdityaDS
20 hours ago
add a comment |
2
Have you tried settingprotected $incrementing = falseon the model?
– Travis Britz
20 hours ago
it seems that I haven't used the code yet.
– AdityaDS
20 hours ago
2
2
Have you tried setting
protected $incrementing = false on the model?– Travis Britz
20 hours ago
Have you tried setting
protected $incrementing = false on the model?– Travis Britz
20 hours ago
it seems that I haven't used the code yet.
– AdityaDS
20 hours ago
it seems that I haven't used the code yet.
– AdityaDS
20 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
based on @Travis Britz comments
I get a solution that I have to add a some line at my model
protected $incrementing = false
on my case i need to change protected to public so the answer is
public $incrementing = false
and this working fine now
My mistake, you're right that the property ispublic. Without this, Laravel assumes that it's an incrementing integer, and casts your string to an int (probably0). Related: stackoverflow.com/a/43691024/6038111
– Travis Britz
19 hours ago
no problem, at least you have helped me.
– AdityaDS
19 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
based on @Travis Britz comments
I get a solution that I have to add a some line at my model
protected $incrementing = false
on my case i need to change protected to public so the answer is
public $incrementing = false
and this working fine now
My mistake, you're right that the property ispublic. Without this, Laravel assumes that it's an incrementing integer, and casts your string to an int (probably0). Related: stackoverflow.com/a/43691024/6038111
– Travis Britz
19 hours ago
no problem, at least you have helped me.
– AdityaDS
19 hours ago
add a comment |
up vote
0
down vote
based on @Travis Britz comments
I get a solution that I have to add a some line at my model
protected $incrementing = false
on my case i need to change protected to public so the answer is
public $incrementing = false
and this working fine now
My mistake, you're right that the property ispublic. Without this, Laravel assumes that it's an incrementing integer, and casts your string to an int (probably0). Related: stackoverflow.com/a/43691024/6038111
– Travis Britz
19 hours ago
no problem, at least you have helped me.
– AdityaDS
19 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
based on @Travis Britz comments
I get a solution that I have to add a some line at my model
protected $incrementing = false
on my case i need to change protected to public so the answer is
public $incrementing = false
and this working fine now
based on @Travis Britz comments
I get a solution that I have to add a some line at my model
protected $incrementing = false
on my case i need to change protected to public so the answer is
public $incrementing = false
and this working fine now
answered 20 hours ago
AdityaDS
177113
177113
My mistake, you're right that the property ispublic. Without this, Laravel assumes that it's an incrementing integer, and casts your string to an int (probably0). Related: stackoverflow.com/a/43691024/6038111
– Travis Britz
19 hours ago
no problem, at least you have helped me.
– AdityaDS
19 hours ago
add a comment |
My mistake, you're right that the property ispublic. Without this, Laravel assumes that it's an incrementing integer, and casts your string to an int (probably0). Related: stackoverflow.com/a/43691024/6038111
– Travis Britz
19 hours ago
no problem, at least you have helped me.
– AdityaDS
19 hours ago
My mistake, you're right that the property is
public. Without this, Laravel assumes that it's an incrementing integer, and casts your string to an int (probably 0). Related: stackoverflow.com/a/43691024/6038111– Travis Britz
19 hours ago
My mistake, you're right that the property is
public. Without this, Laravel assumes that it's an incrementing integer, and casts your string to an int (probably 0). Related: stackoverflow.com/a/43691024/6038111– Travis Britz
19 hours ago
no problem, at least you have helped me.
– AdityaDS
19 hours ago
no problem, at least you have helped me.
– AdityaDS
19 hours ago
add a comment |
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237334%2furi-segment-laravel-not-working-for-string%23new-answer', 'question_page');
);
Post as a guest
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
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
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
2
Have you tried setting
protected $incrementing = falseon the model?– Travis Britz
20 hours ago
it seems that I haven't used the code yet.
– AdityaDS
20 hours ago