예제 #1
0
 public function run()
 {
     $faker = Faker::create();
     $count = 100;
     $region_ids = Region::lists('region_id');
     foreach (range(1, $count) as $i) {
         Quotation::create(['A76_80' => $faker->randomFloat(6, $min = 19, $max = 24), 'A92' => $faker->randomFloat(6, $min = 19, $max = 24), 'A95' => $faker->randomFloat(6, $min = 19, $max = 24), 'region_id' => $faker->randomElement($region_ids), 'added_on' => Carbon::instance($faker->dateTimeBetween('10.07.2015', '16.07.2015'))->toDateString()]);
     }
 }
예제 #2
0
 /**
  * Generates quotation requests
  *
  * @param int $customerId
  * @return Response
  * @author Gat
  **/
 public function createQuotation($customerId)
 {
     $directAward = Input::get('award') ? true : false;
     $customer = Customer::find($customerId);
     $secretary = Auth::user();
     // Check if customer has a representative
     if ($customer->representatives->isEmpty()) {
         return Redirect::route('customers.edit', ['id' => $customerId])->with('message', 'Add a customer representative first')->with('alert-class', 'danger');
     }
     // Get Initials
     $initialsPatern = '~\\b(\\w)|.~';
     $customerInitials = preg_replace($initialsPatern, '$1', $customer->name);
     $secretaryInitials = preg_replace($initialsPatern, '$1', $secretary->full_name);
     // TEMPORARY
     // RFQ = Customer's Initials - DDMM - Secretary's Initials
     $rfq = $customerInitials . '-' . date('dm') . '-' . $secretaryInitials;
     // Append number if existing
     $quotations = Quotation::where('rfq_id', 'LIKE', "{$rfq}%");
     if ($quotations->count()) {
         $rfq = $rfq . '-' . $quotations->count();
     }
     // Create quotation
     $quotation = Quotation::create(['customer_id' => $customer->id, 'secretary_id' => $secretary->id, 'rfq_id' => $rfq, 'direct_award' => $directAward]);
     return Redirect::route('quotations.request', ['rfq' => Str::slug($rfq)]);
 }