vendredi 20 juillet 2018

LARAVEL Posting in Database comes with unwanted quotation marks

I'm currently facing a weird case in Laravel where I input something to the database, but stores it with unwanted quotation marks. Keep in mind I've used str_replace and trim, but still it stores in the database with quotes.

I think it may be because I am retrieving it from an array, but I figured it wouldn't matter because the str_replace and other functions will do the job of removing the quotation marks.

 $tasks = $request->get('task');
    $taskEmployees = $request->get('taskEmployee');
    $taskDeadlines = $request->get('taskDeadline');
    $taskStartDates = $request->get('taskStartDate');
        foreach($tasks as $key => $value) {
          $task = new Task;
          $task->taskName = $tasks[$key];
          $task->employeeAssigned = str_replace('"', "", $taskEmployees[$key]);
          $taskDeadline = trim($taskDeadlines[$key]);
        //  $task->deadline = Carbon::parse($taskDeadline)->format('y-m-d');
        //  $task->startDate = Carbon::parse($taskStartDates[$key])->format('y-m-d');
          $task->project_id = $project->id;
          $task->save();
        }       
    return redirect('/dashboard')-> with('success', 'Project Created');

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire