Inheritance: extends Domain\BaseModel, use trait Illuminate\Database\Eloquent\SoftDeletes
 public function createBillet($student, $refer)
 {
     $due_date = substr($refer, 0, 4) . '-' . substr($refer, -2) . '-';
     $recipient = BilletAssignor::first();
     $data = ['student_id' => $student->id, 'due_date' => $due_date . $student->day_of_payment, 'amount' => $student->monthly_payment, 'agency' => $recipient->agency, 'digit_agency' => $recipient->digit_agency, 'account' => $recipient->account, 'digit_account' => $recipient->digit_account, 'wallet' => $recipient->wallet, 'agreement' => $recipient->agreement, 'portfolio_change' => $recipient->portfolio_change, 'instruction01' => $recipient->instruction01, 'instruction02' => $recipient->instruction02, 'instruction03' => $recipient->instruction03, 'instruction04' => $recipient->instruction04, 'instruction05' => $recipient->instruction05, 'refer' => $refer, 'note' => 'Fatura gerada automaticamente'];
     $billet = new Billet();
     $billet->fill($data);
     $billet->save();
     return $billet;
 }
 public function test_index_returns_billets_by_get()
 {
     Billet::where('id', '>=', 1)->delete();
     $billets = factory(Billet::class, 3)->create();
     $this->get('api/v1/billet');
     $this->seeStatusCode(200);
     foreach ($billets as $billet) {
         $this->seeJson(['amount' => $billet->amount]);
     }
 }
Beispiel #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Schedule::truncate();
     Billet::truncate();
     BilletAssignor::truncate();
     Classroom::truncate();
     ClassroomMatter::truncate();
     Config::truncate();
     Employee::truncate();
     Lesson::truncate();
     Matter::truncate();
     Schedule::truncate();
     Student::truncate();
     Teacher::truncate();
     factory(BilletAssignor::class, 1)->create();
     factory(Billet::class, 5)->create();
     $allClassrooms = factory(Classroom::class, 10)->create();
     factory(ClassroomMatter::class, 10)->create();
     factory(Config::class, 10)->create();
     $employee = factory(Employee::class)->create();
     factory(Lesson::class, 40)->create();
     $matters = factory(Matter::class, 10)->create();
     factory(Schedule::class, 3)->create();
     $student = factory(Student::class)->create();
     $teacher = factory(Teacher::class)->create();
     factory(User::class, 1)->create(['username' => 'funcionario', 'password' => bcrypt('funcionario123'), 'owner_type' => Employee::class, 'owner_id' => $employee->id]);
     factory(User::class, 1)->create(['username' => 'aluno', 'password' => bcrypt('aluno123'), 'owner_type' => Student::class, 'owner_id' => $student->id]);
     factory(User::class, 1)->create(['username' => 'professor', 'password' => bcrypt('professor123'), 'owner_type' => Teacher::class, 'owner_id' => $teacher->id]);
     $classrooms = factory(Classroom::class, 3)->create(['teacher_id' => $teacher->id]);
     $classrooms->each(function ($classroom) use($student, $matters) {
         $classroom->students()->attach($student);
         $matters->random(3)->each(function ($matter) use($classroom) {
             $classroom->matters()->attach($matter);
         });
     });
     $allClassrooms->random(3)->each(function ($classroom) use($student, $matters, $teacher) {
         $classroom->teacher()->associate($teacher);
         $classroom->students()->attach($student);
         $matters->random(3)->each(function ($matter) use($classroom) {
             $classroom->matters()->attach($matter);
         });
     });
     factory(User::class, 30)->create();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Beispiel #4
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $id = $this->route('billet');
     $billet = Billet::where('id', $id)->first();
     return ['amount' => 'required|numeric', 'discount' => 'numeric', 'interest' => 'numeric', 'payment_of_fine' => 'numeric', 'date' => 'date|date_format:Y-m-d', 'refer' => 'required|integer|min:201604|date_format:Ym', 'student_id' => 'in:' . $billet->student_id, 'note' => 'max:65535', 'new_due_date' => 'date|date_format:Y-m-d|after:today', 'statement01' => 'max:30', 'statement02' => 'max:30', 'statement03' => 'max:30', 'statement04' => 'max:30', 'statement05' => 'max:30', 'instruction01' => 'max:30', 'instruction02' => 'max:30', 'instruction03' => 'max:30', 'instruction04' => 'max:30', 'instruction05' => 'max:30', 'acceptance' => 'boolean', 'kind_document' => 'max:3'];
 }