I don't know why I'm not getting the value from the modal in my Laravel controller. Please check it for me.
However, I use the same code for other modes and controllers. It's working and returning the value from the property without any issues.
I'm using Laravel 8 and php 8.1;
Below is my code.
app\Http\Controllers\Admin\MpdController.php
public function edit(mpd $mpd)
{
dd($mpd);
}
app\Models\admin\mpd.php
use App\Models\taxcategories;
class mpd extends Model
{
use HasFactory;
public $table = 'purchdata';
protected $primaryKey = 'sno';
protected $dates = [
'created_at',
'updated_at',
'approved_at',
];
protected $fillable = [
'sno',
'supplier',
'stockid',
'price',
'discount',
'disc_flag',
'tax_category',
'preferred',
'createby',
'modifiedby',
'approvedby',
'history',
];
/**
* Get the tax_category that owns the maintainpurchasingdata
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function tax_category(): BelongsTo
{
return $this->belongsTo(taxcategories::class, 'tax_category', 'taxrate');
}
}
routing\web.php
Route::resource('maintainpurchase', 'MpdController');
Route model binding will automatically determine the variable name based on the name in front of the variable name
For example:
Route::resource('images', 'ImageController')Expect
Image $imageto exist in the controller.Use
php artisan route:listand find the value between brackets and changeto
Or use the parameter function on the routing resource definition to modify the parameter name
Route::resource('maintainpurchase', 'MpdController')->parameter('VALUEBETWEENTHEBRACKET', 'mpd');