laravel
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| laravel [2020/12/23 18:56] – chifek | laravel [2023/09/14 06:06] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Seeders | + | [[laravel-mix|Laravel |
| + | [[laravel-mix-vuejs|Laravel + Laravel Mix + VueJS]] | ||
| - | **Introduction** | + | [[Seeder|Seeder]] |
| + | [[Collections|Collections]] | ||
| - | Laravel includes the ability to seed your database with test data using seed classes. All seed classes are stored in the `database/ | + | [[authSocial|Авторизация через соц. сети]] |
| - | + | [[artisan_shpargalki|artisan shpargalki]] | |
| - | **Writing Seeders** | + | |
| - | + | ||
| - | + | ||
| - | To generate a seeder, execute the `make: | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | A seeder class only contains one method by default: `run`. This method is called when the `db:seed` Artisan command is executed. Within the `run` method, you may insert data into your database however you wish. You may use the query builder to manually insert data or you may use Eloquent model factories. | + | |
| - | + | ||
| - | As an example, let's modify the default DatabaseSeeder class and add a database insert statement to the run method: | + | |
| - | + | ||
| - | < | + | |
| - | <?php | + | |
| - | + | ||
| - | namespace Database\Seeders; | + | |
| - | + | ||
| - | use Illuminate\Database\Seeder; | + | |
| - | use Illuminate\Support\Facades\DB; | + | |
| - | use Illuminate\Support\Facades\Hash; | + | |
| - | use Illuminate\Support\Str; | + | |
| - | + | ||
| - | class DatabaseSeeder extends Seeder | + | |
| - | { | + | |
| - | /** | + | |
| - | * Run the database seeders. | + | |
| - | * | + | |
| - | * @return void | + | |
| - | */ | + | |
| - | public function run() | + | |
| - | { | + | |
| - | DB:: | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | | + | |
| - | } | + | |
| - | } | + | |
| - | </ | + | |
laravel.1608749789.txt.gz · Last modified: 2023/09/14 06:06 (external edit)