Answers for "laravel custom route model binding"

PHP
0

laravel route model binding

Route::get('posts/{post:slug}', function(Post $post) {
    return view('post', [
        'post' => $post
    ]);
});
Posted by: Guest on January-08-2022
-2

laravel model bind with route in model

/**
 * Retrieve the model for a bound value.
 *
 * @param  mixed  $value
 * @param  string|null  $field
 * @return IlluminateDatabaseEloquentModel|null
 */
public function resolveRouteBinding($value, $field = null)
{
    return $this->where('name', $value)->firstOrFail();
}
Posted by: Guest on July-29-2020

Code answers related to "laravel custom route model binding"

Browse Popular Code Answers by Language