Pass value from controller to model in laravel

Created at 09-Aug-2021 , By samar

Pass value from controller to model in laravel

In this tutorial, we will try to find the solution to "Pass value from controller to model in laravel" through programming.

You can pass values or parameters from controller to model in laravel by creating a model instance and calling the model method by using $object->methodName($parameters).
  • Pass parameter values from controller to admin model in laravel

    namespace App\Http\Controllers;
    use Illuminate\Http\Request;
    use App\Models\Admin;
    class AdminController extends Controller
         * Handle an authentication attempt for admin.
         * @return Response
        public function userAuthentication(Request $request)
            $admin = new Admin();
    namespace App;
    use Illuminate\Database\Eloquent\Model;
    class Admin extends Model
        public function checkUserAuthentication($request)
            // Do something with $request

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.