# Autosave Model

Saving Model manually every time using create is a bit tedious, We came up with an easy solution of saving a model.

The function was extended in the main controller, and can easily be called in any controller method.

Here is an example

public function storeTask(){
    $data = request()->all();
    $data['form_model'] = encrypt($this->>api_model);
    /*
     * If we are missing api_model in controller`
     * */
    //$data['form_model'] = encrypt(Task::class);
    $data['user_id'] = \request()->user()->id;
    $task = $this->autoSaveModel($data);
    return [
        'status'=>'success',
        'task'=>$task    
    ]
}