Browse Source

Merge branch 'loparev' of aloparev/digital_college into Develop

!

+ 12 - 2
help/README.md

@@ -3,12 +3,22 @@
 
 
 В этот раздел будет добавляться справочная информация, необходимая для работы
 В этот раздел будет добавляться справочная информация, необходимая для работы
 
 
+**ВНИМАНИЕ!**
+
+При работе с GIT проверьте сохраненные пароли: 
+
+
+| Windows | Сетевые учетные записи |
+|---------|------------------------|
+
+| Mac OS | Связка ключей           |
+|---------|------------------------|
 
 
 ##  Работа с GIT
 ##  Работа с GIT
 Скачать наш проект на рабочий стол
 Скачать наш проект на рабочий стол
+
 ```sh
 ```sh
-cd ~/Desktop
-git clone http://git.kansk-tc.ru/aloparev/digital_college.git
+https://git.kansk-tc.ru/aloparev/digital_college.git
 ```
 ```
 Сброс имен и паролей в GIT
 Сброс имен и паролей в GIT
 ```sh
 ```sh

+ 1 - 0
src/server/app/Models/Courses.php

@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
 
 
 class Courses extends Model
 class Courses extends Model
 {
 {
+    use HasFactory;
    public function teachers(){
    public function teachers(){
        return $this->hasMany(Teachers::class);
        return $this->hasMany(Teachers::class);
    }
    }

+ 2 - 0
src/server/app/Models/Teachers.php

@@ -6,7 +6,9 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Model;
 
 
 class Teachers extends Model
 class Teachers extends Model
+
 {
 {
+    use HasFactory;
     protected $hidden = ['password'];
     protected $hidden = ['password'];
     public function teacher(){
     public function teacher(){
 //        return $this->belongsTo('App\Models\Courses','teacher_id');
 //        return $this->belongsTo('App\Models\Courses','teacher_id');

+ 36 - 0
src/server/database/factories/CoursesFactory.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Database\Factories;
+
+use App\Models\Courses;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class CoursesFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected  $model = Courses::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            'isActive'=>'true',
+            'name'=>$this->faker->name(),
+            'price'=>$this->faker->numberBetween(2000,10000),
+            'period'=>$this->faker->numberBetween(2000-10000),
+            'forma'=>$this->faker->randomElement(array('Очная','Заочная','Дистанционная')),
+            'level'=>$this->faker->text(7),
+            'hours'=>$this->faker->numberBetween(32,64),
+            'teacher_id'=>$this->faker->numberBetween(1,5)
+                //
+        ];
+    }
+}

+ 30 - 0
src/server/database/factories/TeachersFactory.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace Database\Factories;
+
+use App\Models\Teachers;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class TeachersFactory extends Factory
+{
+    /**
+     * The name of the factory's corresponding model.
+     *
+     * @var string
+     */
+    protected $model = Teachers::class;
+
+    /**
+     * Define the model's default state.
+     *
+     * @return array
+     */
+    public function definition()
+    {
+        return [
+            //
+            'name'=>$this->faker->name()
+
+        ];
+    }
+}

+ 8 - 16
src/server/database/migrations/2021_05_25_035618_create_teachers_table.php

@@ -15,23 +15,15 @@ class CreateTeachersTable extends Migration
     {
     {
         Schema::create('teachers', function (Blueprint $table) {
         Schema::create('teachers', function (Blueprint $table) {
             $table->bigIncrements('id');
             $table->bigIncrements('id');
-            $table->string('login');
-            $table->string('password');
-            $table->string('avatar');
-            $table->string('fio');
-            $table->string('duty');
-            $table->string('workplace');
-            $table->string('email');
-            $table->string('country');
-            $table->string('city');
-            $table->string('phone', 20);
-            $table->string('education_place');
-            $table->unsignedBigInteger('user_id');
-            $table->unsignedBigInteger('courses_id');
-            $table->string('api_token')->nullable();
+            $table->string('name');
+            $table->string('grade')->nullable();
+            $table->string('phone', 20)->nullable();
+            $table->string('email')->nullable();
+            $table->unsignedBigInteger('organisation_id')->nullable();
+            $table->unsignedBigInteger('courses_id')->nullable();
             $table->timestamps();
             $table->timestamps();
-
-            $table->foreign('user_id')->on('users')->references('id');
+            $table->foreign('organisation_id')->on('organisations')->references('id');
+            $table->foreign('courses_id')->on('courses')->references('id');
         });
         });
     }
     }
 
 

+ 20 - 0
src/server/database/seeders/CoursesSeeder.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Courses;
+use Illuminate\Database\Seeder;
+
+class CoursesSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        //
+        Courses::factory()->count(20)->create();
+    }
+}

+ 2 - 0
src/server/database/seeders/DatabaseSeeder.php

@@ -14,5 +14,7 @@ class DatabaseSeeder extends Seeder
     public function run()
     public function run()
     {
     {
         // \App\Models\User::factory(10)->create();
         // \App\Models\User::factory(10)->create();
+        $this->call(TeachersSeeder::class);
+        $this->call(CoursesSeeder::class);
     }
     }
 }
 }

+ 21 - 0
src/server/database/seeders/TeachersSeeder.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace Database\Seeders;
+
+use App\Models\Teachers;
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+
+class TeachersSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        //
+        Teachers::factory()->count(5)->create();
+    }
+}

BIN
src/server/storage/db/base.db