public function handle(LoanWasCreated $event)
 {
     $docs = Requireddocument::where('loantype_id', $event->loan->loan_type_id)->get();
     foreach ($docs as $doc) {
         Attachment::create(['loan_id' => $event->loan->id, 'title' => $doc->document]);
     }
 }
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Requireddocument::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
 public function run()
 {
     DB::table('requireddocuments')->delete();
     Requireddocument::create(['loantype_id' => 1, 'document' => "Signed Application"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Signed Application"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Signed Application"]);
     Requireddocument::create(['loantype_id' => 4, 'document' => "Signed Application"]);
     Requireddocument::create(['loantype_id' => 5, 'document' => "Signed Application"]);
     Requireddocument::create(['loantype_id' => 6, 'document' => "Signed Application"]);
     Requireddocument::create(['loantype_id' => 7, 'document' => "Signed Application"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "Driver's License"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Driver's License"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Driver's License"]);
     Requireddocument::create(['loantype_id' => 4, 'document' => "Driver's License"]);
     Requireddocument::create(['loantype_id' => 5, 'document' => "Driver's License"]);
     Requireddocument::create(['loantype_id' => 6, 'document' => "Driver's License"]);
     Requireddocument::create(['loantype_id' => 7, 'document' => "Driver's License"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "Financials"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Financials"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Financials"]);
     Requireddocument::create(['loantype_id' => 4, 'document' => "Financials"]);
     Requireddocument::create(['loantype_id' => 5, 'document' => "Financials"]);
     Requireddocument::create(['loantype_id' => 6, 'document' => "Financials"]);
     Requireddocument::create(['loantype_id' => 7, 'document' => "Financials"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "Equipment List"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Equipment List"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Equipment List"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "Leases"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Leases"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Leases"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "FSA Information"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "FSA Information"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "FSA Information"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "Insurance Information"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Insurance Information"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Insurance Information"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "Crop Insurance APH Database"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Crop Insurance APH Database"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Crop Insurance APH Database"]);
     Requireddocument::create(['loantype_id' => 1, 'document' => "Grain Contracts"]);
     Requireddocument::create(['loantype_id' => 2, 'document' => "Grain Contracts"]);
     Requireddocument::create(['loantype_id' => 3, 'document' => "Grain Contracts"]);
     Requireddocument::create(['loantype_id' => 6, 'document' => "Grain Contracts"]);
 }