skip to Main Content

I fill a SQL Table from a Request with Laravel Excel.
After this I do an Eloquent Statement to fill the values markt and period manually.

public function importall(Request $request)
{
    $periode = $request->periode;
    $markt = $request->markt;
    Excel::import(new periodenImport(), $request->file);            // Datei Import

    /*
    PlanspielData::where('periode', ' ')                        
    ->update(['periode' => $periode]);                      // Daten der Periode zuordnen
   
    PlanspielData::where('markt', ' ')  
    ->update(['markt' => $markt]);                         // Daten einem Markt zuordnen
    */
    return redirect('/import')->with('success-upload', 'Sucess');
}

I want to pass more then the file from the Request to the newperiodenImport to delete the commented area with Planspieldata.

2

Answers


  1. You don’t need to pass the request to anywhere, you can simply call request()->input('X');

    Login or Signup to reply.
  2. you can make a __construct in the class and pass data to it
    example:

     class periodenImport implements ToCollection,WithHeadingRow,SkipsEmptyRows
        {
          private $periode;
          private $markt;
        
          public function __construct($periode, $markt)
          {
            $this->periode = $periode;
            $this->markt = $markt;
          }
        }
    

    public function importall(Request $request)
    {
      $periode = $request->periode;
      $markt = $request->markt;
       Excel::import(new periodenImport($periode,$markt), $request->file); 
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search