Pass value from controller to model in laravel

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).

Answers 1
  • 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