php - how to run method in model instead of controller in laravel 5.1? -
i have following method in controller:
public function store() { $data=input::all(); user::create($data); }
the above code works perfectly. question can run above method in model without writing in controller? , best approach?
you can try following way
in model
public function insetuser() { $input = input::all(); user::create($input); //here instead of user,you can use self self::create($input); }
in controller can
public function store() { user::insetuser(); }
Comments
Post a Comment