├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── README.md ├── app ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Admin │ │ │ └── IndexController.php │ │ ├── Api │ │ │ └── V1 │ │ │ │ └── UserController.php │ │ ├── Controller.php │ │ ├── EloquentController.php │ │ ├── IndexController.php │ │ ├── ItemController.php │ │ ├── UserController.php │ │ └── UserCrudController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ ├── ValidateSignature.php │ │ └── VerifyCsrfToken.php │ └── Requests │ │ └── ItemStoreRequest.php ├── Models │ ├── Article.php │ ├── Category.php │ ├── Item.php │ └── User.php ├── Policies │ └── ItemPolicy.php └── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── config ├── app.php ├── auth.php ├── cache.php ├── database.php ├── filesystems.php ├── logging.php ├── mail.php ├── queue.php ├── sanctum.php ├── services.php └── session.php ├── database ├── .gitignore ├── factories │ ├── ArticleFactory.php │ ├── CategoryFactory.php │ ├── ItemFactory.php │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2021_11_18_142420_create_products_table.php │ └── tasks │ │ └── 2021_11_18_122318_create_posts_table.php └── seeders │ └── DatabaseSeeder.php ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── robots.txt └── web.config ├── resources ├── css │ └── app.css ├── js │ ├── app.js │ └── bootstrap.js ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── auth.blade.php │ ├── eloquent │ ├── task2.blade.php │ └── task4.blade.php │ ├── hello.blade.php │ ├── layouts │ └── app.blade.php │ ├── login.blade.php │ ├── pages │ └── contact.blade.php │ ├── shared │ ├── empty.blade.php │ ├── menu.blade.php │ └── user.blade.php │ ├── table.blade.php │ ├── users │ ├── form.blade.php │ ├── index.blade.php │ └── show.blade.php │ └── welcome.blade.php ├── routes ├── api.php ├── console.php ├── default.php └── web.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── debugbar │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ ├── AuthTest.php │ ├── BladeTest.php │ ├── MigrationsTest.php │ ├── ModelTest.php │ ├── RouteTest.php │ └── ValidationTest.php └── TestCase.php └── vite.config.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_TIMEZONE=UTC 6 | APP_URL=http://localhost 7 | 8 | APP_LOCALE=en 9 | APP_FALLBACK_LOCALE=en 10 | APP_FAKER_LOCALE=en_US 11 | 12 | APP_MAINTENANCE_DRIVER=file 13 | # APP_MAINTENANCE_STORE=database 14 | 15 | BCRYPT_ROUNDS=12 16 | 17 | LOG_CHANNEL=stack 18 | LOG_STACK=single 19 | LOG_DEPRECATIONS_CHANNEL=null 20 | LOG_LEVEL=debug 21 | 22 | DB_CONNECTION=mysql 23 | DB_HOST=127.0.0.1 24 | DB_PORT=3306 25 | DB_DATABASE=laravel_skill_test 26 | DB_USERNAME=root 27 | DB_PASSWORD= 28 | 29 | SESSION_DRIVER=file 30 | SESSION_LIFETIME=120 31 | SESSION_ENCRYPT=false 32 | SESSION_PATH=/ 33 | SESSION_DOMAIN=null 34 | 35 | BROADCAST_CONNECTION=log 36 | FILESYSTEM_DISK=local 37 | QUEUE_CONNECTION=sync 38 | 39 | CACHE_STORE=file 40 | CACHE_PREFIX= 41 | 42 | MEMCACHED_HOST=127.0.0.1 43 | 44 | REDIS_CLIENT=phpredis 45 | REDIS_HOST=127.0.0.1 46 | REDIS_PASSWORD=null 47 | REDIS_PORT=6379 48 | 49 | MAIL_MAILER=log 50 | MAIL_HOST=127.0.0.1 51 | MAIL_PORT=2525 52 | MAIL_USERNAME=null 53 | MAIL_PASSWORD=null 54 | MAIL_ENCRYPTION=null 55 | MAIL_FROM_ADDRESS="hello@example.com" 56 | MAIL_FROM_NAME="${APP_NAME}" 57 | 58 | AWS_ACCESS_KEY_ID= 59 | AWS_SECRET_ACCESS_KEY= 60 | AWS_DEFAULT_REGION=us-east-1 61 | AWS_BUCKET= 62 | AWS_USE_PATH_STYLE_ENDPOINT=false 63 | 64 | VITE_APP_NAME="${APP_NAME}" 65 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | .styleci.yml export-ignore 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /vendor 8 | .env 9 | .env.backup 10 | .env.production 11 | .phpactor.json 12 | .phpunit.result.cache 13 | docker-compose.override.yml 14 | Homestead.json 15 | Homestead.yaml 16 | auth.json 17 | npm-debug.log 18 | yarn-error.log 19 | /.fleet 20 | /.idea 21 | /.vscode 22 | composer.lock 23 | /_docker 24 | docker-compose.yml 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Тест на знание основ laravel 2 | 3 | Репозиторий служит целью проверки знаний основ фреймворка laravel, в рамках тем указанных в roadmap здесь: 4 | [CutCode Junior Roadmap](https://cutcode.dev/roadmap) 5 | 6 | [Видео инструкции](https://www.youtube.com/watch?v=bYDfOLhqKaE) 7 | 8 | Цель создания такого тестирования было охватить базовые разделы laravel и научиться на практике покрывать тестами проект на laravel. 9 | 10 | # Оглавление по темам 11 | 1. [Миграции](#task-migrations) 12 | 2. [Маршрутизация](#task-route) 13 | 3. [Blade template](#task-blade) 14 | 4. [Eloquent model](#task-model) 15 | 5. [Валидация](#task-validation) 16 | 6. [Аутентификация](#task-auth) 17 | 18 | Для начала необходимо развернуть проект на котором будут выполняться тесты. 19 | 20 | # Установка 21 | - `composer install` 22 | - `php artisan key:generate` 23 | - .env с реквизитами mysql базы данных 24 | - КРАЙНЕ ВАЖНО ЧТОБЫ БАЗА ДАННЫХ НАЗЫВАЛАСЬ laravel_skill_test 25 | 26 | # Потребуется 27 | - php >= 7.3 28 | - mysql 29 | 30 | # Проверка 31 | - `php artisan test --filter MigrationsTest` 32 | - `php artisan test --filter RouteTest` 33 | - `php artisan test --filter BladeTest` 34 | - `php artisan test --filter ModelTest` 35 | - `php artisan test --filter ValidationTest` 36 | - `php artisan test --filter AuthTest` 37 | - `php artisan test` 38 | 39 | 40 | # Инструкции 41 | Искать задачи можно по фильтру TODO в IDE (игнорируя директорию /storage), либо по списку заданий 42 | 43 | # Подтверждение выполнения теста 44 | PR в ветку master (автоматически запустит тест проверки) 45 | 46 | # Задания 47 | 48 | ## 1) Миграции 49 | Все задания находятся здесь `database/migrations/tasks` 50 | - Тесты `tests/Feature/MigrationsTest.php` 51 | - Запуск `php artisan test --filter MigrationsTest` 52 | 53 | --- 54 | #### Задание 1: Новая таблица 55 | Создать в базе данных таблицу categories с 2 полями id и title (не забыть про timestamps) 56 | 57 | --- 58 | #### Задание 2: Nullable 59 | Для title указать что значение по умолчанию NULL 60 | 61 | --- 62 | #### Задание 3: Значение по умолчанию 63 | Для active указать что значение по умолчанию TRUE 64 | 65 | --- 66 | #### Задание 4: Soft Deleting 67 | Добавить функционал soft delete 68 | 69 | --- 70 | #### Задание 5: Timestamps 71 | Добавить поля с timestamps (created_at, updated_at) через 1 метод 72 | 73 | --- 74 | #### Задание 6: Новое поле с указанием порядка 75 | Добавить поле description типа text (DEFAULT NULL) ПОСЛЕ поля title 76 | 77 | --- 78 | #### Задание 7: Проверка наличия поля 79 | Сделать провеку на наличие поля active и в случаи успеха добавить поле main (boolean default false) 80 | 81 | --- 82 | #### Задание 8: Переименовать поле 83 | Переименовать поле title в name 84 | 85 | --- 86 | #### Задание 9: Переименовать таблицу 87 | Переименовать таблицу posts в articles 88 | 89 | --- 90 | #### Задание 10: belongsToMany 91 | Добавить таблицу для связи articles и categories (belongsToMany) c foreign ключами 92 | 93 | --- 94 | ## 2) Маршрутизация (Route) 95 | Все задания находятся здесь `routes/web.php` и `routes/api.php` 96 | - Тесты `tests/Feature/RouteTest.php` 97 | - Запуск `php artisan test --filter RouteTest` 98 | 99 | --- 100 | #### Задание 1: View 101 | По GET урлу /hello отобразить view - /resources/views/hello.blade (без контроллера) 102 | 103 | --- 104 | #### Задание 2: Controller 105 | По GET урлу / обратиться к IndexController, метод index 106 | 107 | --- 108 | #### Задание 3: View с наименованием роута 109 | По GET урлу /page/contact отобразить view - /resources/views/pages/contact.blade 110 | с наименованием роута - contact 111 | 112 | --- 113 | #### Задание 4: Параметры 114 | По GET урлу /users/[id] обратиться к UserController -> метод show 115 | без Route Model Binding. Только параметр id 116 | 117 | --- 118 | #### Задание 5: Model Binding 119 | По GET урлу /users/bind/[user] обратиться к UserController -> метод showBind 120 | но в данном случае используем Route Model Binding. Параметр user 121 | 122 | --- 123 | #### Задание 6: Редирект 124 | Выполнить редирект с урла /bad на урл /good 125 | 126 | --- 127 | #### Задание 7: Resource controller 128 | Добавить роут на ресурс контроллер - UserCrudController с урлом - /users_crud 129 | 130 | --- 131 | #### Задание 8: Группировка 132 | Организовать группу роутов (Route::group()) объединенных префиксом - dashboard 133 | 134 | --- 135 | #### Задание 9: Группировка подзадачи 136 | Добавить роут GET /admin -> Admin/IndexController -> index 137 | 138 | --- 139 | #### Задание 10: Группировка подзадачи 140 | Добавить роут POST /admin/post -> Admin/IndexController -> post 141 | 142 | --- 143 | #### Задание 11: Middleware 144 | Организовать группу роутов (Route::group()) объединенных префиксом - security и мидлваром auth 145 | 146 | --- 147 | #### Задание 12: Middleware подзадачи 148 | Добавить роут GET /admin/auth -> Admin/IndexController -> auth 149 | 150 | --- 151 | #### Задание 13: ApiResource (routes/api.php) 152 | Добавить apiResource контроллер - Api/V1/UserController 153 | - Префикс урла должен быть /api/v1 154 | - Полный урл /api/v1/users (не забывайте что это api routes) 155 | 156 | ## 3) Blade template 157 | - Тесты `tests/Feature/BladeTest.php` 158 | - Запуск `php artisan test --filter BladeTest` 159 | 160 | --- 161 | #### Задание 1: Передать данные во view 162 | `Http/Controllers/IndexController.php` 163 | Передайте users во view (название ключа users) 164 | 165 | --- 166 | #### Задание 2: Layout 167 | `resources/views/table.blade.php` 168 | Изменить реализацию этой view, расширить ее с использованием layout 169 | 170 | --- 171 | #### Задание 3: Include 172 | `resources/views/layouts/app.blade.php` 173 | Подключите view с меню shared/menu.blade.php 174 | 175 | --- 176 | #### Задание 4: Auth 177 | `resources/views/auth.blade.php` 178 | Сделать проверку авторизован пользователь или нет. 179 | Если да то вывести ID пользователя. 180 | ID пользователя вывести внутри конструкции с проверкой 181 | 182 | --- 183 | #### Задание 5: Component 184 | `resources/views/welcome.blade.php` 185 | Сделать blade component с названием HelloWorld с содержимым во view - Текущая дата в формате Y-m-d. 186 | - Обязательное условие добавить регистрацию компонента в AppServiceProvider и изменить его alias на hello 187 | - В итоге alias - hello а класс компонента App\View\Components\HelloWorld 188 | - Вывести его в указаном месте 189 | 190 | --- 191 | #### Задание 6: Each 192 | `resources/views/table.blade.php` 193 | В эту view с контроллера передается collection c users в переменной data. 194 | - Выполнить foreach loop в одну строку (специальная директива) 195 | - Используйте view shared/user.blade.php для item (переменная user во item view) 196 | - Используйте view shared/empty.blade.php для состояния когда нет элементов 197 | 198 | --- 199 | #### Задание 7: ForEach 200 | `resources/views/table.blade.php` 201 | Здесь сделайте классический foreach loop 202 | - Выведите div с $user->name 203 | - Воспользуйтесь переменной $loop и у нечетных div выведите класс - `bg-red-500` 204 | 205 | ## 4) Eloquent Models 206 | - Тесты `tests/Feature/ModelTest.php` 207 | - Запуск `php artisan test --filter ModelTest` 208 | 209 | --- 210 | #### Задание 1: Таблица 211 | `Models/Item.php` 212 | Указать что таблица у модели - products 213 | 214 | --- 215 | #### Задание 2: Basic query 216 | `Http/Controllers/EloquentController.php` 217 | С помощью модели Item реализовать запрос 218 | - `select * from products where active = true order by created_at desc limit 3` 219 | 220 | --- 221 | #### Задание 3: Scopes 222 | `Http/Controllers/EloquentController.php` 223 | Добавить в модель Item scope для фильтрации активных продуктов (scopeActive()) 224 | 225 | --- 226 | #### Задание 4: 404 227 | `Http/Controllers/EloquentController.php` 228 | Найти Item по id и передать во view либо отдать 404 страницу 229 | 230 | --- 231 | #### Задание 5: Create 232 | `Http/Controllers/EloquentController.php` 233 | Выполнить простое добавление новой записи 234 | 235 | --- 236 | #### Задание 6: Update 237 | `Http/Controllers/EloquentController.php` 238 | Выполнить простое обновление записи 239 | 240 | --- 241 | #### Задание 7: Delete 242 | `Http/Controllers/EloquentController.php` 243 | Выполнить массовое удаление записей 244 | 245 | 246 | ## 5) Валидация 247 | - Тесты `tests/Feature/ValidationTest.php` 248 | - Запуск `php artisan test --filter ValidationTest` 249 | 250 | --- 251 | #### Задание 252 | `Http/Requests/ItemStoreRequest.php` 253 | Добавить правила валидации для поля title 254 | - Поле обязательно 255 | - Строковое 256 | - Минимам 5 символов 257 | - Максимум 15 символов 258 | 259 | ## 6) Аутентификация 260 | - Тесты `tests/Feature/AuthTest.php` 261 | - Запуск `php artisan test --filter AuthTest` 262 | 263 | --- 264 | #### Задание 265 | `Policies/ItemPolicy.php` 266 | Разрешить добавление продуктов только пользователю с id = 10 267 | 268 | # Возникли сложности 269 | 270 | Есть предложения? Возникли какие-либо проблемы? Не стестняйтесь и пишите GitHub Issues. 271 | 272 | Желаю всем удачи! 273 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 16 | } 17 | 18 | /** 19 | * Register the commands for the application. 20 | */ 21 | protected function commands(): void 22 | { 23 | $this->load(__DIR__.'/Commands'); 24 | 25 | require base_path('routes/console.php'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $dontFlash = [ 16 | 'current_password', 17 | 'password', 18 | 'password_confirmation', 19 | ]; 20 | 21 | /** 22 | * Register the exception handling callbacks for the application. 23 | */ 24 | public function register(): void 25 | { 26 | $this->reportable(function (Throwable $e) { 27 | // 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/IndexController.php: -------------------------------------------------------------------------------- 1 | validate([ 25 | 'name' => 'required', 26 | 'email' => 'required', 27 | 'password' => 'required' 28 | ])); 29 | } 30 | 31 | /** 32 | * Display the specified resource. 33 | */ 34 | public function show(User $user) 35 | { 36 | return $user; 37 | } 38 | 39 | /** 40 | * Update the specified resource in storage. 41 | */ 42 | public function update(Request $request, User $user) 43 | { 44 | return $user->update($request->validate([ 45 | 'name' => 'required', 46 | 'email' => 'required', 47 | 'password' => 'required' 48 | ])); 49 | } 50 | 51 | /** 52 | * Remove the specified resource from storage. 53 | */ 54 | public function destroy(User $user) 55 | { 56 | $user->delete(); 57 | 58 | return response()->noContent(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | $products 19 | ]); 20 | } 21 | 22 | public function task3() 23 | { 24 | // TODO Eloquent Задание 3: Добавить в модель Item scope для фильтрации активных продуктов (scopeActive()) 25 | // Одна строка кода вместо [] 26 | $products = []; 27 | 28 | return view('eloquent.task2', [ 29 | 'products' => $products 30 | ]); 31 | } 32 | 33 | public function task4(int $id) 34 | { 35 | // TODO Eloquent Задание 4: Найти Item по id и передать во view либо отдать 404 страницу 36 | // Одна строка кода вместо [] 37 | $product = []; 38 | 39 | return view('eloquent.task4', [ 40 | 'product' => $product 41 | ]); 42 | } 43 | 44 | public function task5(Request $request) 45 | { 46 | // TODO Eloquent Задание 5: В запросе будет все необходимое для создания записи 47 | // Выполнить простое добавление новой записи в Item на основе $request 48 | 49 | return redirect('/'); 50 | } 51 | 52 | public function task6(int $id, Request $request) 53 | { 54 | $product = Item::findOrFail($id); 55 | // TODO Eloquent Задание 6: В запросе будет все необходимое для обновления записи 56 | // Выполнить простое обновление записи на основе $request 57 | 58 | return redirect('/'); 59 | } 60 | 61 | public function task7(Request $request) 62 | { 63 | // TODO Eloquent Задание 7: В запросе будет параметр products, который будет содержать массив с id 64 | // [1,2,3,4 ...] выполнить массовое удаление записей модели Item с учетом id в $request 65 | 66 | return redirect('/'); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/Http/Controllers/IndexController.php: -------------------------------------------------------------------------------- 1 | 'Welcome', 16 | // TODO Blade Задание 1: Передайте users во view (название ключа users) 17 | ]); 18 | } 19 | 20 | public function table() 21 | { 22 | return view('table', [ 23 | 'data' => User::all(), 24 | ]); 25 | } 26 | 27 | public function auth() 28 | { 29 | return view('auth'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Controllers/ItemController.php: -------------------------------------------------------------------------------- 1 | User::all() 17 | ]); 18 | } 19 | 20 | /** 21 | * Show the form for creating a new resource. 22 | */ 23 | public function create() 24 | { 25 | return view('users.form'); 26 | } 27 | 28 | /** 29 | * Store a newly created resource in storage. 30 | */ 31 | public function store(Request $request) 32 | { 33 | User::create($request->validate([ 34 | 'name' => 'required', 35 | 'email' => 'required', 36 | 'password' => 'required' 37 | ])); 38 | 39 | return redirect('/users_crud'); 40 | } 41 | 42 | /** 43 | * Display the specified resource. 44 | */ 45 | public function show(User $user) 46 | { 47 | return view('users.show', compact('user')); 48 | } 49 | 50 | /** 51 | * Show the form for editing the specified resource. 52 | */ 53 | public function edit(User $user) 54 | { 55 | return view('users.form', compact('user')); 56 | } 57 | 58 | /** 59 | * Update the specified resource in storage. 60 | */ 61 | public function update(Request $request, User $user) 62 | { 63 | $user->update($request->validate([ 64 | 'name' => 'required', 65 | 'email' => 'required', 66 | 'password' => 'required' 67 | ])); 68 | 69 | return redirect('/users_crud'); 70 | } 71 | 72 | /** 73 | * Remove the specified resource from storage. 74 | */ 75 | public function destroy(User $user) 76 | { 77 | $user->delete(); 78 | 79 | return redirect('/users_crud'); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Illuminate\Http\Middleware\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 37 | \App\Http\Middleware\VerifyCsrfToken::class, 38 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 39 | ], 40 | 41 | 'api' => [ 42 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 43 | \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | ], 46 | ]; 47 | 48 | /** 49 | * The application's middleware aliases. 50 | * 51 | * Aliases may be used instead of class names to conveniently assign middleware to routes and groups. 52 | * 53 | * @var array 54 | */ 55 | protected $middlewareAliases = [ 56 | 'auth' => \App\Http\Middleware\Authenticate::class, 57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 58 | 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 63 | 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, 64 | 'signed' => \App\Http\Middleware\ValidateSignature::class, 65 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 66 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 67 | ]; 68 | } 69 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Requests/ItemStoreRequest.php: -------------------------------------------------------------------------------- 1 | |string> 21 | */ 22 | public function rules(): array 23 | { 24 | return [ 25 | // TODO Validation Задание: Добавить правила валидации для поля title 26 | // Поле обязательно, строковое, минимум 5 символов, максимум 15 символов 27 | ]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Models/Article.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Category::class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Models/Category.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | protected $fillable = [ 21 | 'name', 22 | 'email', 23 | 'password', 24 | ]; 25 | 26 | /** 27 | * The attributes that should be hidden for serialization. 28 | * 29 | * @var array 30 | */ 31 | protected $hidden = [ 32 | 'password', 33 | 'remember_token', 34 | ]; 35 | 36 | /** 37 | * The attributes that should be cast. 38 | * 39 | * @var array 40 | */ 41 | protected $casts = [ 42 | 'email_verified_at' => 'datetime', 43 | 'password' => 'hashed', 44 | ]; 45 | } 46 | -------------------------------------------------------------------------------- /app/Policies/ItemPolicy.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | */ 22 | public function boot(): void 23 | { 24 | // 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | */ 26 | public function boot(): void 27 | { 28 | // 29 | } 30 | 31 | /** 32 | * Determine if events and listeners should be automatically discovered. 33 | */ 34 | public function shouldDiscoverEvents(): bool 35 | { 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | by($request->user()?->id ?: $request->ip()); 29 | }); 30 | 31 | $this->routes(function () { 32 | Route::middleware('api') 33 | ->prefix('api') 34 | ->group(base_path('routes/api.php')); 35 | 36 | Route::middleware('web') 37 | ->group(base_path('routes/web.php')); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | handleCommand(new ArgvInput); 14 | 15 | exit($status); 16 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The skeleton application for the Laravel framework.", 5 | "keywords": ["laravel", "framework"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^8.2", 9 | "guzzlehttp/guzzle": "^7.2", 10 | "laravel/framework": "^11.20", 11 | "laravel/sanctum": "^4.0", 12 | "laravel/tinker": "^2.9" 13 | }, 14 | "require-dev": { 15 | "barryvdh/laravel-debugbar": "^3.13", 16 | "fakerphp/faker": "^1.23", 17 | "laravel/pint": "^1.13", 18 | "laravel/sail": "^1.26", 19 | "mockery/mockery": "^1.6", 20 | "nunomaduro/collision": "^8.0", 21 | "phpunit/phpunit": "^11.0.1" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "App\\": "app/", 26 | "Database\\Factories\\": "database/factories/", 27 | "Database\\Seeders\\": "database/seeders/" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "Tests\\": "tests/" 33 | } 34 | }, 35 | "scripts": { 36 | "post-autoload-dump": [ 37 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 38 | "@php artisan package:discover --ansi" 39 | ], 40 | "post-update-cmd": [ 41 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 42 | ], 43 | "post-root-package-install": [ 44 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 45 | ], 46 | "post-create-project-cmd": [ 47 | "@php artisan key:generate --ansi", 48 | "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"", 49 | "@php artisan migrate --graceful --ansi" 50 | ] 51 | }, 52 | "extra": { 53 | "laravel": { 54 | "dont-discover": [] 55 | } 56 | }, 57 | "config": { 58 | "optimize-autoloader": true, 59 | "preferred-install": "dist", 60 | "sort-packages": true, 61 | "allow-plugins": { 62 | "pestphp/pest-plugin": true, 63 | "php-http/discovery": true 64 | } 65 | }, 66 | "minimum-stability": "stable", 67 | "prefer-stable": true 68 | } 69 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Application Environment 24 | |-------------------------------------------------------------------------- 25 | | 26 | | This value determines the "environment" your application is currently 27 | | running in. This may determine how you prefer to configure various 28 | | services the application utilizes. Set this in your ".env" file. 29 | | 30 | */ 31 | 32 | 'env' => env('APP_ENV', 'production'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Application Debug Mode 37 | |-------------------------------------------------------------------------- 38 | | 39 | | When your application is in debug mode, detailed error messages with 40 | | stack traces will be shown on every error that occurs within your 41 | | application. If disabled, a simple generic error page is shown. 42 | | 43 | */ 44 | 45 | 'debug' => (bool) env('APP_DEBUG', false), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Application URL 50 | |-------------------------------------------------------------------------- 51 | | 52 | | This URL is used by the console to properly generate URLs when using 53 | | the Artisan command line tool. You should set this to the root of 54 | | the application so that it's available within Artisan commands. 55 | | 56 | */ 57 | 58 | 'url' => env('APP_URL', 'http://localhost'), 59 | 60 | /* 61 | |-------------------------------------------------------------------------- 62 | | Application Timezone 63 | |-------------------------------------------------------------------------- 64 | | 65 | | Here you may specify the default timezone for your application, which 66 | | will be used by the PHP date and date-time functions. The timezone 67 | | is set to "UTC" by default as it is suitable for most use cases. 68 | | 69 | */ 70 | 71 | 'timezone' => env('APP_TIMEZONE', 'UTC'), 72 | 73 | /* 74 | |-------------------------------------------------------------------------- 75 | | Application Locale Configuration 76 | |-------------------------------------------------------------------------- 77 | | 78 | | The application locale determines the default locale that will be used 79 | | by Laravel's translation / localization methods. This option can be 80 | | set to any locale for which you plan to have translation strings. 81 | | 82 | */ 83 | 84 | 'locale' => env('APP_LOCALE', 'en'), 85 | 86 | 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), 87 | 88 | 'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'), 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Encryption Key 93 | |-------------------------------------------------------------------------- 94 | | 95 | | This key is utilized by Laravel's encryption services and should be set 96 | | to a random, 32 character string to ensure that all encrypted values 97 | | are secure. You should do this prior to deploying the application. 98 | | 99 | */ 100 | 101 | 'cipher' => 'AES-256-CBC', 102 | 103 | 'key' => env('APP_KEY'), 104 | 105 | 'previous_keys' => [ 106 | ...array_filter( 107 | explode(',', env('APP_PREVIOUS_KEYS', '')) 108 | ), 109 | ], 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Maintenance Mode Driver 114 | |-------------------------------------------------------------------------- 115 | | 116 | | These configuration options determine the driver used to determine and 117 | | manage Laravel's "maintenance mode" status. The "cache" driver will 118 | | allow maintenance mode to be controlled across multiple machines. 119 | | 120 | | Supported drivers: "file", "cache" 121 | | 122 | */ 123 | 124 | 'maintenance' => [ 125 | 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), 126 | 'store' => env('APP_MAINTENANCE_STORE', 'database'), 127 | ], 128 | 129 | /* 130 | |-------------------------------------------------------------------------- 131 | | Autoloaded Service Providers 132 | |-------------------------------------------------------------------------- 133 | | 134 | | The service providers listed here will be automatically loaded on the 135 | | request to your application. Feel free to add your own services to 136 | | this array to grant expanded functionality to your applications. 137 | | 138 | */ 139 | 140 | 'providers' => ServiceProvider::defaultProviders()->merge([ 141 | /* 142 | * Package Service Providers... 143 | */ 144 | 145 | /* 146 | * Application Service Providers... 147 | */ 148 | App\Providers\AppServiceProvider::class, 149 | App\Providers\AuthServiceProvider::class, 150 | // App\Providers\BroadcastServiceProvider::class, 151 | App\Providers\EventServiceProvider::class, 152 | App\Providers\RouteServiceProvider::class, 153 | ])->toArray(), 154 | 155 | /* 156 | |-------------------------------------------------------------------------- 157 | | Class Aliases 158 | |-------------------------------------------------------------------------- 159 | | 160 | | This array of class aliases will be registered when this application 161 | | is started. However, feel free to register as many as you wish as 162 | | the aliases are "lazy" loaded so they don't hinder performance. 163 | | 164 | */ 165 | 166 | 'aliases' => Facade::defaultAliases()->merge([ 167 | // 'Example' => App\Facades\Example::class, 168 | ])->toArray(), 169 | 170 | ]; 171 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => env('AUTH_GUARD', 'web'), 18 | 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'), 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | which utilizes session storage plus the Eloquent user provider. 29 | | 30 | | All authentication guards have a user provider, which defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | system used by the application. Typically, Eloquent is utilized. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication guards have a user provider, which defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | system used by the application. Typically, Eloquent is utilized. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | providers to represent the model / table. These providers may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => env('AUTH_MODEL', App\Models\User::class), 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | These configuration options specify the behavior of Laravel's password 80 | | reset functionality, including the table utilized for token storage 81 | | and the user provider that is invoked to actually retrieve users. 82 | | 83 | | The expiry time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | | The throttle setting is the number of seconds a user must wait before 88 | | generating more password reset tokens. This prevents the user from 89 | | quickly generating a very large amount of password reset tokens. 90 | | 91 | */ 92 | 93 | 'passwords' => [ 94 | 'users' => [ 95 | 'provider' => 'users', 96 | 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'), 97 | 'expire' => 60, 98 | 'throttle' => 60, 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Password Confirmation Timeout 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Here you may define the amount of seconds before a password confirmation 108 | | window expires and users are asked to re-enter their password via the 109 | | confirmation screen. By default, the timeout lasts for three hours. 110 | | 111 | */ 112 | 113 | 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800), 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_STORE', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "array", "database", "file", "memcached", 30 | | "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'array' => [ 37 | 'driver' => 'array', 38 | 'serialize' => false, 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'connection' => env('DB_CACHE_CONNECTION'), 44 | 'table' => env('DB_CACHE_TABLE', 'cache'), 45 | 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), 46 | 'lock_table' => env('DB_CACHE_LOCK_TABLE'), 47 | ], 48 | 49 | 'file' => [ 50 | 'driver' => 'file', 51 | 'path' => storage_path('framework/cache/data'), 52 | 'lock_path' => storage_path('framework/cache/data'), 53 | ], 54 | 55 | 'memcached' => [ 56 | 'driver' => 'memcached', 57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 58 | 'sasl' => [ 59 | env('MEMCACHED_USERNAME'), 60 | env('MEMCACHED_PASSWORD'), 61 | ], 62 | 'options' => [ 63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 64 | ], 65 | 'servers' => [ 66 | [ 67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 68 | 'port' => env('MEMCACHED_PORT', 11211), 69 | 'weight' => 100, 70 | ], 71 | ], 72 | ], 73 | 74 | 'redis' => [ 75 | 'driver' => 'redis', 76 | 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), 77 | 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), 78 | ], 79 | 80 | 'dynamodb' => [ 81 | 'driver' => 'dynamodb', 82 | 'key' => env('AWS_ACCESS_KEY_ID'), 83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 86 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 87 | ], 88 | 89 | 'octane' => [ 90 | 'driver' => 'octane', 91 | ], 92 | 93 | ], 94 | 95 | /* 96 | |-------------------------------------------------------------------------- 97 | | Cache Key Prefix 98 | |-------------------------------------------------------------------------- 99 | | 100 | | When utilizing the APC, database, memcached, Redis, and DynamoDB cache 101 | | stores, there might be other applications using the same cache. For 102 | | that reason, you may prefix every cache key to avoid collisions. 103 | | 104 | */ 105 | 106 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 107 | 108 | ]; 109 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Database Connections 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Below are all of the database connections defined for your application. 27 | | An example configuration is provided for each database system which 28 | | is supported by Laravel. You're free to add / remove connections. 29 | | 30 | */ 31 | 32 | 'connections' => [ 33 | 34 | 'sqlite' => [ 35 | 'driver' => 'sqlite', 36 | 'url' => env('DB_URL'), 37 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 38 | 'prefix' => '', 39 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 40 | 'busy_timeout' => null, 41 | 'journal_mode' => null, 42 | 'synchronous' => null, 43 | ], 44 | 45 | 'mysql' => [ 46 | 'driver' => 'mysql', 47 | 'url' => env('DB_URL'), 48 | 'host' => env('DB_HOST', '127.0.0.1'), 49 | 'port' => env('DB_PORT', '3306'), 50 | 'database' => env('DB_DATABASE', 'laravel'), 51 | 'username' => env('DB_USERNAME', 'root'), 52 | 'password' => env('DB_PASSWORD', ''), 53 | 'unix_socket' => env('DB_SOCKET', ''), 54 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 55 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 56 | 'prefix' => '', 57 | 'prefix_indexes' => true, 58 | 'strict' => true, 59 | 'engine' => null, 60 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 61 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 62 | ]) : [], 63 | ], 64 | 65 | 'mariadb' => [ 66 | 'driver' => 'mariadb', 67 | 'url' => env('DB_URL'), 68 | 'host' => env('DB_HOST', '127.0.0.1'), 69 | 'port' => env('DB_PORT', '3306'), 70 | 'database' => env('DB_DATABASE', 'laravel'), 71 | 'username' => env('DB_USERNAME', 'root'), 72 | 'password' => env('DB_PASSWORD', ''), 73 | 'unix_socket' => env('DB_SOCKET', ''), 74 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 75 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 76 | 'prefix' => '', 77 | 'prefix_indexes' => true, 78 | 'strict' => true, 79 | 'engine' => null, 80 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 81 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 82 | ]) : [], 83 | ], 84 | 85 | 'pgsql' => [ 86 | 'driver' => 'pgsql', 87 | 'url' => env('DB_URL'), 88 | 'host' => env('DB_HOST', '127.0.0.1'), 89 | 'port' => env('DB_PORT', '5432'), 90 | 'database' => env('DB_DATABASE', 'laravel'), 91 | 'username' => env('DB_USERNAME', 'root'), 92 | 'password' => env('DB_PASSWORD', ''), 93 | 'charset' => env('DB_CHARSET', 'utf8'), 94 | 'prefix' => '', 95 | 'prefix_indexes' => true, 96 | 'search_path' => 'public', 97 | 'sslmode' => 'prefer', 98 | ], 99 | 100 | 'sqlsrv' => [ 101 | 'driver' => 'sqlsrv', 102 | 'url' => env('DB_URL'), 103 | 'host' => env('DB_HOST', 'localhost'), 104 | 'port' => env('DB_PORT', '1433'), 105 | 'database' => env('DB_DATABASE', 'laravel'), 106 | 'username' => env('DB_USERNAME', 'root'), 107 | 'password' => env('DB_PASSWORD', ''), 108 | 'charset' => env('DB_CHARSET', 'utf8'), 109 | 'prefix' => '', 110 | 'prefix_indexes' => true, 111 | // 'encrypt' => env('DB_ENCRYPT', 'yes'), 112 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), 113 | ], 114 | 115 | ], 116 | 117 | /* 118 | |-------------------------------------------------------------------------- 119 | | Migration Repository Table 120 | |-------------------------------------------------------------------------- 121 | | 122 | | This table keeps track of all the migrations that have already run for 123 | | your application. Using this information, we can determine which of 124 | | the migrations on disk haven't actually been run on the database. 125 | | 126 | */ 127 | 128 | 'migrations' => [ 129 | 'table' => 'migrations', 130 | 'update_date_on_publish' => true, 131 | ], 132 | 133 | /* 134 | |-------------------------------------------------------------------------- 135 | | Redis Databases 136 | |-------------------------------------------------------------------------- 137 | | 138 | | Redis is an open source, fast, and advanced key-value store that also 139 | | provides a richer body of commands than a typical key-value system 140 | | such as Memcached. You may define your connection settings here. 141 | | 142 | */ 143 | 144 | 'redis' => [ 145 | 146 | 'client' => env('REDIS_CLIENT', 'phpredis'), 147 | 148 | 'options' => [ 149 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 150 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 151 | ], 152 | 153 | 'default' => [ 154 | 'url' => env('REDIS_URL'), 155 | 'host' => env('REDIS_HOST', '127.0.0.1'), 156 | 'username' => env('REDIS_USERNAME'), 157 | 'password' => env('REDIS_PASSWORD'), 158 | 'port' => env('REDIS_PORT', '6379'), 159 | 'database' => env('REDIS_DB', '0'), 160 | ], 161 | 162 | 'cache' => [ 163 | 'url' => env('REDIS_URL'), 164 | 'host' => env('REDIS_HOST', '127.0.0.1'), 165 | 'username' => env('REDIS_USERNAME'), 166 | 'password' => env('REDIS_PASSWORD'), 167 | 'port' => env('REDIS_PORT', '6379'), 168 | 'database' => env('REDIS_CACHE_DB', '1'), 169 | ], 170 | 171 | ], 172 | 173 | ]; 174 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Below you may configure as many filesystem disks as necessary, and you 24 | | may even configure multiple disks for the same driver. Examples for 25 | | most supported storage drivers are configured here for reference. 26 | | 27 | | Supported drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Deprecations Log Channel 26 | |-------------------------------------------------------------------------- 27 | | 28 | | This option controls the log channel that should be used to log warnings 29 | | regarding deprecated PHP and library features. This allows you to get 30 | | your application ready for upcoming major versions of dependencies. 31 | | 32 | */ 33 | 34 | 'deprecations' => [ 35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 36 | 'trace' => env('LOG_DEPRECATIONS_TRACE', false), 37 | ], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Log Channels 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Here you may configure the log channels for your application. Laravel 45 | | utilizes the Monolog PHP logging library, which includes a variety 46 | | of powerful log handlers and formatters that you're free to use. 47 | | 48 | | Available drivers: "single", "daily", "slack", "syslog", 49 | | "errorlog", "monolog", "custom", "stack" 50 | | 51 | */ 52 | 53 | 'channels' => [ 54 | 55 | 'stack' => [ 56 | 'driver' => 'stack', 57 | 'channels' => explode(',', env('LOG_STACK', 'single')), 58 | 'ignore_exceptions' => false, 59 | ], 60 | 61 | 'single' => [ 62 | 'driver' => 'single', 63 | 'path' => storage_path('logs/laravel.log'), 64 | 'level' => env('LOG_LEVEL', 'debug'), 65 | 'replace_placeholders' => true, 66 | ], 67 | 68 | 'daily' => [ 69 | 'driver' => 'daily', 70 | 'path' => storage_path('logs/laravel.log'), 71 | 'level' => env('LOG_LEVEL', 'debug'), 72 | 'days' => env('LOG_DAILY_DAYS', 14), 73 | 'replace_placeholders' => true, 74 | ], 75 | 76 | 'slack' => [ 77 | 'driver' => 'slack', 78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 79 | 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), 80 | 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), 81 | 'level' => env('LOG_LEVEL', 'critical'), 82 | 'replace_placeholders' => true, 83 | ], 84 | 85 | 'papertrail' => [ 86 | 'driver' => 'monolog', 87 | 'level' => env('LOG_LEVEL', 'debug'), 88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 89 | 'handler_with' => [ 90 | 'host' => env('PAPERTRAIL_URL'), 91 | 'port' => env('PAPERTRAIL_PORT'), 92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 93 | ], 94 | 'processors' => [PsrLogMessageProcessor::class], 95 | ], 96 | 97 | 'stderr' => [ 98 | 'driver' => 'monolog', 99 | 'level' => env('LOG_LEVEL', 'debug'), 100 | 'handler' => StreamHandler::class, 101 | 'formatter' => env('LOG_STDERR_FORMATTER'), 102 | 'with' => [ 103 | 'stream' => 'php://stderr', 104 | ], 105 | 'processors' => [PsrLogMessageProcessor::class], 106 | ], 107 | 108 | 'syslog' => [ 109 | 'driver' => 'syslog', 110 | 'level' => env('LOG_LEVEL', 'debug'), 111 | 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER), 112 | 'replace_placeholders' => true, 113 | ], 114 | 115 | 'errorlog' => [ 116 | 'driver' => 'errorlog', 117 | 'level' => env('LOG_LEVEL', 'debug'), 118 | 'replace_placeholders' => true, 119 | ], 120 | 121 | 'null' => [ 122 | 'driver' => 'monolog', 123 | 'handler' => NullHandler::class, 124 | ], 125 | 126 | 'emergency' => [ 127 | 'path' => storage_path('logs/laravel.log'), 128 | ], 129 | 130 | ], 131 | 132 | ]; 133 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'log'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Mailer Configurations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Here you may configure all of the mailers used by your application plus 25 | | their respective settings. Several examples have been configured for 26 | | you and you are free to add your own as your application requires. 27 | | 28 | | Laravel supports a variety of mail "transport" drivers that can be used 29 | | when delivering an email. You may specify which one you're using for 30 | | your mailers below. You may also add additional mailers if needed. 31 | | 32 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 33 | | "postmark", "resend", "log", "array", 34 | | "failover", "roundrobin" 35 | | 36 | */ 37 | 38 | 'mailers' => [ 39 | 40 | 'smtp' => [ 41 | 'transport' => 'smtp', 42 | 'url' => env('MAIL_URL'), 43 | 'host' => env('MAIL_HOST', '127.0.0.1'), 44 | 'port' => env('MAIL_PORT', 2525), 45 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 46 | 'username' => env('MAIL_USERNAME'), 47 | 'password' => env('MAIL_PASSWORD'), 48 | 'timeout' => null, 49 | 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)), 50 | ], 51 | 52 | 'ses' => [ 53 | 'transport' => 'ses', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), 59 | // 'client' => [ 60 | // 'timeout' => 5, 61 | // ], 62 | ], 63 | 64 | 'resend' => [ 65 | 'transport' => 'resend', 66 | ], 67 | 68 | 'sendmail' => [ 69 | 'transport' => 'sendmail', 70 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 71 | ], 72 | 73 | 'log' => [ 74 | 'transport' => 'log', 75 | 'channel' => env('MAIL_LOG_CHANNEL'), 76 | ], 77 | 78 | 'array' => [ 79 | 'transport' => 'array', 80 | ], 81 | 82 | 'failover' => [ 83 | 'transport' => 'failover', 84 | 'mailers' => [ 85 | 'smtp', 86 | 'log', 87 | ], 88 | ], 89 | 90 | 'roundrobin' => [ 91 | 'transport' => 'roundrobin', 92 | 'mailers' => [ 93 | 'ses', 94 | 'postmark', 95 | ], 96 | ], 97 | 98 | ], 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Global "From" Address 103 | |-------------------------------------------------------------------------- 104 | | 105 | | You may wish for all emails sent by your application to be sent from 106 | | the same address. Here you may specify a name and address that is 107 | | used globally for all emails that are sent by your application. 108 | | 109 | */ 110 | 111 | 'from' => [ 112 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 113 | 'name' => env('MAIL_FROM_NAME', 'Example'), 114 | ], 115 | 116 | ]; 117 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'database'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection options for every queue backend 24 | | used by your application. An example configuration is provided for 25 | | each backend supported by Laravel. You're also free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'connection' => env('DB_QUEUE_CONNECTION'), 40 | 'table' => env('DB_QUEUE_TABLE', 'jobs'), 41 | 'queue' => env('DB_QUEUE', 'default'), 42 | 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90), 43 | 'after_commit' => false, 44 | ], 45 | 46 | 'beanstalkd' => [ 47 | 'driver' => 'beanstalkd', 48 | 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), 49 | 'queue' => env('BEANSTALKD_QUEUE', 'default'), 50 | 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), 51 | 'block_for' => 0, 52 | 'after_commit' => false, 53 | ], 54 | 55 | 'sqs' => [ 56 | 'driver' => 'sqs', 57 | 'key' => env('AWS_ACCESS_KEY_ID'), 58 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 59 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 60 | 'queue' => env('SQS_QUEUE', 'default'), 61 | 'suffix' => env('SQS_SUFFIX'), 62 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 63 | 'after_commit' => false, 64 | ], 65 | 66 | 'redis' => [ 67 | 'driver' => 'redis', 68 | 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 69 | 'queue' => env('REDIS_QUEUE', 'default'), 70 | 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90), 71 | 'block_for' => null, 72 | 'after_commit' => false, 73 | ], 74 | 75 | ], 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Job Batching 80 | |-------------------------------------------------------------------------- 81 | | 82 | | The following options configure the database and table that store job 83 | | batching information. These options can be updated to any database 84 | | connection and table which has been defined by your application. 85 | | 86 | */ 87 | 88 | 'batching' => [ 89 | 'database' => env('DB_CONNECTION', 'mysql'), 90 | 'table' => 'job_batches', 91 | ], 92 | 93 | /* 94 | |-------------------------------------------------------------------------- 95 | | Failed Queue Jobs 96 | |-------------------------------------------------------------------------- 97 | | 98 | | These options configure the behavior of failed queue job logging so you 99 | | can control how and where failed jobs are stored. Laravel ships with 100 | | support for storing failed jobs in a simple file or in a database. 101 | | 102 | | Supported drivers: "database-uuids", "dynamodb", "file", "null" 103 | | 104 | */ 105 | 106 | 'failed' => [ 107 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 108 | 'database' => env('DB_CONNECTION', 'sqlite'), 109 | 'table' => 'failed_jobs', 110 | ], 111 | 112 | ]; 113 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | 2 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 20 | '%s%s', 21 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 22 | Sanctum::currentApplicationUrlWithPort() 23 | ))), 24 | 25 | /* 26 | |-------------------------------------------------------------------------- 27 | | Sanctum Guards 28 | |-------------------------------------------------------------------------- 29 | | 30 | | This array contains the authentication guards that will be checked when 31 | | Sanctum is trying to authenticate a request. If none of these guards 32 | | are able to authenticate the request, Sanctum will use the bearer 33 | | token that's present on an incoming request for authentication. 34 | | 35 | */ 36 | 37 | 'guard' => ['web'], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Expiration Minutes 42 | |-------------------------------------------------------------------------- 43 | | 44 | | This value controls the number of minutes until an issued token will be 45 | | considered expired. This will override any values set in the token's 46 | | "expires_at" attribute, but first-party sessions are not affected. 47 | | 48 | */ 49 | 50 | 'expiration' => null, 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Token Prefix 55 | |-------------------------------------------------------------------------- 56 | | 57 | | Sanctum can prefix new tokens in order to take advantage of numerous 58 | | security scanning initiatives maintained by open source platforms 59 | | that notify developers if they commit tokens into repositories. 60 | | 61 | | See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning 62 | | 63 | */ 64 | 65 | 'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''), 66 | 67 | /* 68 | |-------------------------------------------------------------------------- 69 | | Sanctum Middleware 70 | |-------------------------------------------------------------------------- 71 | | 72 | | When authenticating your first-party SPA with Sanctum you may need to 73 | | customize some of the middleware Sanctum uses while processing the 74 | | request. You may change the middleware listed below as required. 75 | | 76 | */ 77 | 78 | 'middleware' => [ 79 | 'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class, 80 | 'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class, 81 | 'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class, 82 | ], 83 | 84 | ]; 85 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'token' => env('POSTMARK_TOKEN'), 19 | ], 20 | 21 | 'ses' => [ 22 | 'key' => env('AWS_ACCESS_KEY_ID'), 23 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 24 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 25 | ], 26 | 27 | 'resend' => [ 28 | 'key' => env('RESEND_KEY'), 29 | ], 30 | 31 | 'slack' => [ 32 | 'notifications' => [ 33 | 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), 34 | 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), 35 | ], 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'database'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to expire immediately when the browser is closed then you may 31 | | indicate that via the expire_on_close configuration option. 32 | | 33 | */ 34 | 35 | 'lifetime' => env('SESSION_LIFETIME', 120), 36 | 37 | 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Session Encryption 42 | |-------------------------------------------------------------------------- 43 | | 44 | | This option allows you to easily specify that all of your session data 45 | | should be encrypted before it's stored. All encryption is performed 46 | | automatically by Laravel and you may use the session like normal. 47 | | 48 | */ 49 | 50 | 'encrypt' => env('SESSION_ENCRYPT', false), 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Session File Location 55 | |-------------------------------------------------------------------------- 56 | | 57 | | When utilizing the "file" session driver, the session files are placed 58 | | on disk. The default storage location is defined here; however, you 59 | | are free to provide another location where they should be stored. 60 | | 61 | */ 62 | 63 | 'files' => storage_path('framework/sessions'), 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Session Database Connection 68 | |-------------------------------------------------------------------------- 69 | | 70 | | When using the "database" or "redis" session drivers, you may specify a 71 | | connection that should be used to manage these sessions. This should 72 | | correspond to a connection in your database configuration options. 73 | | 74 | */ 75 | 76 | 'connection' => env('SESSION_CONNECTION'), 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Session Database Table 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When using the "database" session driver, you may specify the table to 84 | | be used to store sessions. Of course, a sensible default is defined 85 | | for you; however, you're welcome to change this to another table. 86 | | 87 | */ 88 | 89 | 'table' => env('SESSION_TABLE', 'sessions'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Session Cache Store 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using one of the framework's cache driven session backends, you may 97 | | define the cache store which should be used to store the session data 98 | | between requests. This must match one of your defined cache stores. 99 | | 100 | | Affects: "apc", "dynamodb", "memcached", "redis" 101 | | 102 | */ 103 | 104 | 'store' => env('SESSION_STORE'), 105 | 106 | /* 107 | |-------------------------------------------------------------------------- 108 | | Session Sweeping Lottery 109 | |-------------------------------------------------------------------------- 110 | | 111 | | Some session drivers must manually sweep their storage location to get 112 | | rid of old sessions from storage. Here are the chances that it will 113 | | happen on a given request. By default, the odds are 2 out of 100. 114 | | 115 | */ 116 | 117 | 'lottery' => [2, 100], 118 | 119 | /* 120 | |-------------------------------------------------------------------------- 121 | | Session Cookie Name 122 | |-------------------------------------------------------------------------- 123 | | 124 | | Here you may change the name of the session cookie that is created by 125 | | the framework. Typically, you should not need to change this value 126 | | since doing so does not grant a meaningful security improvement. 127 | | 128 | */ 129 | 130 | 'cookie' => env( 131 | 'SESSION_COOKIE', 132 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 133 | ), 134 | 135 | /* 136 | |-------------------------------------------------------------------------- 137 | | Session Cookie Path 138 | |-------------------------------------------------------------------------- 139 | | 140 | | The session cookie path determines the path for which the cookie will 141 | | be regarded as available. Typically, this will be the root path of 142 | | your application, but you're free to change this when necessary. 143 | | 144 | */ 145 | 146 | 'path' => env('SESSION_PATH', '/'), 147 | 148 | /* 149 | |-------------------------------------------------------------------------- 150 | | Session Cookie Domain 151 | |-------------------------------------------------------------------------- 152 | | 153 | | This value determines the domain and subdomains the session cookie is 154 | | available to. By default, the cookie will be available to the root 155 | | domain and all subdomains. Typically, this shouldn't be changed. 156 | | 157 | */ 158 | 159 | 'domain' => env('SESSION_DOMAIN'), 160 | 161 | /* 162 | |-------------------------------------------------------------------------- 163 | | HTTPS Only Cookies 164 | |-------------------------------------------------------------------------- 165 | | 166 | | By setting this option to true, session cookies will only be sent back 167 | | to the server if the browser has a HTTPS connection. This will keep 168 | | the cookie from being sent to you when it can't be done securely. 169 | | 170 | */ 171 | 172 | 'secure' => env('SESSION_SECURE_COOKIE'), 173 | 174 | /* 175 | |-------------------------------------------------------------------------- 176 | | HTTP Access Only 177 | |-------------------------------------------------------------------------- 178 | | 179 | | Setting this value to true will prevent JavaScript from accessing the 180 | | value of the cookie and the cookie will only be accessible through 181 | | the HTTP protocol. It's unlikely you should disable this option. 182 | | 183 | */ 184 | 185 | 'http_only' => env('SESSION_HTTP_ONLY', true), 186 | 187 | /* 188 | |-------------------------------------------------------------------------- 189 | | Same-Site Cookies 190 | |-------------------------------------------------------------------------- 191 | | 192 | | This option determines how your cookies behave when cross-site requests 193 | | take place, and can be used to mitigate CSRF attacks. By default, we 194 | | will set this value to "lax" to permit secure cross-site requests. 195 | | 196 | | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value 197 | | 198 | | Supported: "lax", "strict", "none", null 199 | | 200 | */ 201 | 202 | 'same_site' => env('SESSION_SAME_SITE', 'lax'), 203 | 204 | /* 205 | |-------------------------------------------------------------------------- 206 | | Partitioned Cookies 207 | |-------------------------------------------------------------------------- 208 | | 209 | | Setting this value to true will tie the cookie to the top-level site for 210 | | a cross-site context. Partitioned cookies are accepted by the browser 211 | | when flagged "secure" and the Same-Site attribute is set to "none". 212 | | 213 | */ 214 | 215 | 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), 216 | 217 | ]; 218 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /database/factories/ArticleFactory.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function definition(): array 15 | { 16 | return [ 17 | 'name' => fake()->words(2, true), 18 | 'description' => fake()->text, 19 | 'active' => fake()->boolean, 20 | 'main' => fake()->boolean 21 | ]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/factories/CategoryFactory.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function definition(): array 15 | { 16 | return [ 17 | 'title' => fake()->words(2, true) 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /database/factories/ItemFactory.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function definition(): array 15 | { 16 | return [ 17 | 'title' => fake()->words(2, true), 18 | 'active' => fake()->boolean, 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * The current password being used by the factory. 16 | */ 17 | protected static ?string $password; 18 | 19 | /** 20 | * Define the model's default state. 21 | * 22 | * @return array 23 | */ 24 | public function definition(): array 25 | { 26 | return [ 27 | 'name' => fake()->name(), 28 | 'email' => fake()->unique()->safeEmail(), 29 | 'email_verified_at' => now(), 30 | 'password' => static::$password ??= Hash::make('password'), 31 | 'remember_token' => Str::random(10), 32 | ]; 33 | } 34 | 35 | /** 36 | * Indicate that the model's email address should be unverified. 37 | */ 38 | public function unverified(): static 39 | { 40 | return $this->state(fn (array $attributes) => [ 41 | 'email_verified_at' => null, 42 | ]); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('users'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/migrations/2021_11_18_142420_create_products_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('title'); 17 | $table->boolean('active')->default(false); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | */ 25 | public function down(): void 26 | { 27 | Schema::dropIfExists('products'); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /database/migrations/tasks/2021_11_18_122318_create_posts_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | 19 | //TODO Migrations Задание 2: Для title указать что значение по умолчанию NULL 20 | 21 | //TODO Migrations Задание 3: Для active указать что значение по умолчанию TRUE 22 | 23 | //TODO Migrations Задание 4: Добавить функционал soft delete 24 | 25 | //TODO Migrations Задание 5: Добавить поля с timestamps (created_at, updated_at) через 1 метод 26 | }); 27 | 28 | Schema::table('posts', function (Blueprint $table) { 29 | //TODO Migrations Задание 6: Добавить поле description типа text (DEFAULT NULL) ПОСЛЕ поля title 30 | 31 | //TODO Migrations Задание 7: Сделать проверку на наличие поля active и в случаи успеха добавить поле main (boolean default false) 32 | 33 | //TODO Migrations Задание 8: Переименовать поле title в name 34 | }); 35 | 36 | //TODO Migrations Задание 9: Переименовать таблицу posts в articles 37 | 38 | //TODO Migrations Задание 10: Добавить таблицу для связи articles и categories (belongsToMany) c foreign ключами 39 | } 40 | 41 | /** 42 | * Reverse the migrations. 43 | */ 44 | public function down(): void 45 | { 46 | // TODO Migrations Задание 11: Удалить таблицы categories, articles, article_category если такие существуют 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build" 7 | }, 8 | "devDependencies": { 9 | "axios": "^1.6.4", 10 | "laravel-vite-plugin": "^1.0", 11 | "vite": "^5.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests/Feature 10 | 11 | 12 | 13 | 14 | app 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lee-to/laravel-check-your-skill-test/954f79a0e161ce27e9cc724adba30a54ce3d7778/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lee-to/laravel-check-your-skill-test/954f79a0e161ce27e9cc724adba30a54ce3d7778/resources/css/app.css -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // forceTLS: true 28 | // }); 29 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'password' => 'The provided password is incorrect.', 18 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'accepted_if' => 'The :attribute must be accepted when :other is :value.', 18 | 'active_url' => 'The :attribute is not a valid URL.', 19 | 'after' => 'The :attribute must be a date after :date.', 20 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 21 | 'alpha' => 'The :attribute must only contain letters.', 22 | 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.', 23 | 'alpha_num' => 'The :attribute must only contain letters and numbers.', 24 | 'array' => 'The :attribute must be an array.', 25 | 'before' => 'The :attribute must be a date before :date.', 26 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 27 | 'between' => [ 28 | 'numeric' => 'The :attribute must be between :min and :max.', 29 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 30 | 'string' => 'The :attribute must be between :min and :max characters.', 31 | 'array' => 'The :attribute must have between :min and :max items.', 32 | ], 33 | 'boolean' => 'The :attribute field must be true or false.', 34 | 'confirmed' => 'The :attribute confirmation does not match.', 35 | 'current_password' => 'The password is incorrect.', 36 | 'date' => 'The :attribute is not a valid date.', 37 | 'date_equals' => 'The :attribute must be a date equal to :date.', 38 | 'date_format' => 'The :attribute does not match the format :format.', 39 | 'declined' => 'The :attribute must be declined.', 40 | 'declined_if' => 'The :attribute must be declined when :other is :value.', 41 | 'different' => 'The :attribute and :other must be different.', 42 | 'digits' => 'The :attribute must be :digits digits.', 43 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 44 | 'dimensions' => 'The :attribute has invalid image dimensions.', 45 | 'distinct' => 'The :attribute field has a duplicate value.', 46 | 'email' => 'The :attribute must be a valid email address.', 47 | 'ends_with' => 'The :attribute must end with one of the following: :values.', 48 | 'exists' => 'The selected :attribute is invalid.', 49 | 'file' => 'The :attribute must be a file.', 50 | 'filled' => 'The :attribute field must have a value.', 51 | 'gt' => [ 52 | 'numeric' => 'The :attribute must be greater than :value.', 53 | 'file' => 'The :attribute must be greater than :value kilobytes.', 54 | 'string' => 'The :attribute must be greater than :value characters.', 55 | 'array' => 'The :attribute must have more than :value items.', 56 | ], 57 | 'gte' => [ 58 | 'numeric' => 'The :attribute must be greater than or equal to :value.', 59 | 'file' => 'The :attribute must be greater than or equal to :value kilobytes.', 60 | 'string' => 'The :attribute must be greater than or equal to :value characters.', 61 | 'array' => 'The :attribute must have :value items or more.', 62 | ], 63 | 'image' => 'The :attribute must be an image.', 64 | 'in' => 'The selected :attribute is invalid.', 65 | 'in_array' => 'The :attribute field does not exist in :other.', 66 | 'integer' => 'The :attribute must be an integer.', 67 | 'ip' => 'The :attribute must be a valid IP address.', 68 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 69 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 70 | 'json' => 'The :attribute must be a valid JSON string.', 71 | 'lt' => [ 72 | 'numeric' => 'The :attribute must be less than :value.', 73 | 'file' => 'The :attribute must be less than :value kilobytes.', 74 | 'string' => 'The :attribute must be less than :value characters.', 75 | 'array' => 'The :attribute must have less than :value items.', 76 | ], 77 | 'lte' => [ 78 | 'numeric' => 'The :attribute must be less than or equal to :value.', 79 | 'file' => 'The :attribute must be less than or equal to :value kilobytes.', 80 | 'string' => 'The :attribute must be less than or equal to :value characters.', 81 | 'array' => 'The :attribute must not have more than :value items.', 82 | ], 83 | 'max' => [ 84 | 'numeric' => 'The :attribute must not be greater than :max.', 85 | 'file' => 'The :attribute must not be greater than :max kilobytes.', 86 | 'string' => 'The :attribute must not be greater than :max characters.', 87 | 'array' => 'The :attribute must not have more than :max items.', 88 | ], 89 | 'mimes' => 'The :attribute must be a file of type: :values.', 90 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 91 | 'min' => [ 92 | 'numeric' => 'The :attribute must be at least :min.', 93 | 'file' => 'The :attribute must be at least :min kilobytes.', 94 | 'string' => 'The :attribute must be at least :min characters.', 95 | 'array' => 'The :attribute must have at least :min items.', 96 | ], 97 | 'multiple_of' => 'The :attribute must be a multiple of :value.', 98 | 'not_in' => 'The selected :attribute is invalid.', 99 | 'not_regex' => 'The :attribute format is invalid.', 100 | 'numeric' => 'The :attribute must be a number.', 101 | 'password' => 'The password is incorrect.', 102 | 'present' => 'The :attribute field must be present.', 103 | 'regex' => 'The :attribute format is invalid.', 104 | 'required' => 'The :attribute field is required.', 105 | 'required_if' => 'The :attribute field is required when :other is :value.', 106 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 107 | 'required_with' => 'The :attribute field is required when :values is present.', 108 | 'required_with_all' => 'The :attribute field is required when :values are present.', 109 | 'required_without' => 'The :attribute field is required when :values is not present.', 110 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 111 | 'prohibited' => 'The :attribute field is prohibited.', 112 | 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', 113 | 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', 114 | 'prohibits' => 'The :attribute field prohibits :other from being present.', 115 | 'same' => 'The :attribute and :other must match.', 116 | 'size' => [ 117 | 'numeric' => 'The :attribute must be :size.', 118 | 'file' => 'The :attribute must be :size kilobytes.', 119 | 'string' => 'The :attribute must be :size characters.', 120 | 'array' => 'The :attribute must contain :size items.', 121 | ], 122 | 'starts_with' => 'The :attribute must start with one of the following: :values.', 123 | 'string' => 'The :attribute must be a string.', 124 | 'timezone' => 'The :attribute must be a valid timezone.', 125 | 'unique' => 'The :attribute has already been taken.', 126 | 'uploaded' => 'The :attribute failed to upload.', 127 | 'url' => 'The :attribute must be a valid URL.', 128 | 'uuid' => 'The :attribute must be a valid UUID.', 129 | 130 | /* 131 | |-------------------------------------------------------------------------- 132 | | Custom Validation Language Lines 133 | |-------------------------------------------------------------------------- 134 | | 135 | | Here you may specify custom validation messages for attributes using the 136 | | convention "attribute.rule" to name the lines. This makes it quick to 137 | | specify a specific custom language line for a given attribute rule. 138 | | 139 | */ 140 | 141 | 'custom' => [ 142 | 'attribute-name' => [ 143 | 'rule-name' => 'custom-message', 144 | ], 145 | ], 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Custom Validation Attributes 150 | |-------------------------------------------------------------------------- 151 | | 152 | | The following language lines are used to swap our attribute placeholder 153 | | with something more reader friendly such as "E-Mail Address" instead 154 | | of "email". This simply helps us make our message more expressive. 155 | | 156 | */ 157 | 158 | 'attributes' => [], 159 | 160 | ]; 161 | -------------------------------------------------------------------------------- /resources/views/auth.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /resources/views/eloquent/task2.blade.php: -------------------------------------------------------------------------------- 1 | @foreach($products as $product) 2 |
{{ $loop->iteration }}.{{ $product->title }}
3 | @endforeach 4 | -------------------------------------------------------------------------------- /resources/views/eloquent/task4.blade.php: -------------------------------------------------------------------------------- 1 | @isset($product->title) 2 | {{ $product->title }} 3 | @endisset 4 | -------------------------------------------------------------------------------- /resources/views/hello.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Hello 8 | 9 | 10 |

Hello

11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Layout 8 | 9 | 10 | 11 | 12 | 13 | @yield('content') 14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/views/login.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Empty page 8 | 9 | 10 |

Empty page

11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/views/pages/contact.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Empty page 8 | 9 | 10 |

Empty page

11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/views/shared/empty.blade.php: -------------------------------------------------------------------------------- 1 |

Ничего не найдено

-------------------------------------------------------------------------------- /resources/views/shared/menu.blade.php: -------------------------------------------------------------------------------- 1 |
    2 |
  • Menu Item 1
  • 3 |
  • Menu Item 2
  • 4 |
  • Menu Item 3
  • 5 |
-------------------------------------------------------------------------------- /resources/views/shared/user.blade.php: -------------------------------------------------------------------------------- 1 |
2 | {{ $user->name }} 3 |
-------------------------------------------------------------------------------- /resources/views/table.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /resources/views/users/form.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Empty page 8 | 9 | 10 |

Empty page

11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/views/users/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Empty page 8 | 9 | 10 |

Empty page

11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/views/users/show.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{ $user->name }} 8 | 9 | 10 |

{{ $user->name }}

11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 7 | return $request->user(); 8 | }); 9 | 10 | Route::group(['middleware' => 'auth:sanctum'], function() { 11 | // TODO Route Задача 13: Добавить apiResource контроллер - Api/V1/UserController. 12 | // Префикс урла должен быть /api/v1 13 | // Полный урл /api/v1/users (не забывайте что это api routes) 14 | // Одна строка кода 15 | }); 16 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 8 | })->purpose('Display an inspiring quote')->hourly(); 9 | -------------------------------------------------------------------------------- /routes/default.php: -------------------------------------------------------------------------------- 1 | name('login'); 6 | 7 | Route::get('/table', [\App\Http\Controllers\IndexController::class, 'table'])->name('table'); 8 | 9 | Route::get('/auth', [\App\Http\Controllers\IndexController::class, 'auth'])->name('default.auth'); 10 | 11 | Route::get('/eloquent/task2', [\App\Http\Controllers\EloquentController::class, 'task2'])->name('eloquent.task2'); 12 | Route::get('/eloquent/task3', [\App\Http\Controllers\EloquentController::class, 'task3'])->name('eloquent.task3'); 13 | Route::get('/eloquent/task4/{id}', [\App\Http\Controllers\EloquentController::class, 'task4'])->name('eloquent.task4'); 14 | 15 | Route::post('/eloquent/task5', [\App\Http\Controllers\EloquentController::class, 'task5'])->name('eloquent.task5'); 16 | Route::post('/eloquent/task6/{id}', [\App\Http\Controllers\EloquentController::class, 'task6'])->name('eloquent.task6'); 17 | Route::delete('/eloquent/task7', [\App\Http\Controllers\EloquentController::class, 'task7'])->name('eloquent.task7'); 18 | 19 | 20 | Route::resource('items', \App\Http\Controllers\ItemController::class); -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | Admin/IndexController -> index 40 | 41 | 42 | //TODO Route Задание 10: Добавить роут POST /admin/post -> Admin/IndexController -> post 43 | 44 | 45 | //TODO Route Задание 11: Организовать группу роутов (Route::group()) объединенных префиксом - security и мидлваром auth 46 | 47 | // Задачи внутри группы роутов security 48 | //TODO Задание 12: Добавить роут GET /admin/auth -> Admin/IndexController -> auth 49 | 50 | require __DIR__ . '/default.php'; 51 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/debugbar/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Feature/AuthTest.php: -------------------------------------------------------------------------------- 1 | create(['id' => 1]); 17 | 18 | $this->assertFalse($user->can('create', Item::class)); 19 | 20 | $user = User::factory()->create(['id' => 10]); 21 | 22 | $this->assertTrue($user->can('create', Item::class)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/Feature/BladeTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 17 | 18 | $response->assertOk(); 19 | $response->assertViewIs('welcome'); 20 | $response->assertViewHas('users'); 21 | } 22 | 23 | public function test_task_2(): void 24 | { 25 | $response = $this->get('/table'); 26 | 27 | $response->assertOk(); 28 | $response->assertSee('Layout'); 29 | } 30 | 31 | public function test_task_3(): void 32 | { 33 | $response = $this->get('/table'); 34 | 35 | $response->assertOk(); 36 | $response->assertSee('Menu Item 1'); 37 | } 38 | 39 | public function test_task_4(): void 40 | { 41 | $user = User::factory()->create(); 42 | 43 | $response = $this->get('/auth'); 44 | $response->assertOk(); 45 | $response->assertDontSee($user->id); 46 | 47 | $response = $this->actingAs($user)->get('/auth'); 48 | $response->assertOk(); 49 | $response->assertSee($user->id); 50 | } 51 | 52 | public function test_task_5(): void 53 | { 54 | $aliases = Blade::getClassComponentAliases(); 55 | 56 | $this->assertTrue(isset($aliases['hello'])); 57 | 58 | $response = $this->get('/'); 59 | $response->assertOk(); 60 | 61 | $response->assertSee(now()->format('Y-m-d')); 62 | } 63 | 64 | public function test_task_6_7(): void 65 | { 66 | $response = $this->get('/table'); 67 | $response->assertDontSee(`class="bg-red-500"`); 68 | $this->assertStringContainsString('Ничего не найдено', $response->content()); 69 | 70 | User::factory()->count(10)->create(); 71 | 72 | $response = $this->get('/table'); 73 | $response->assertSee(`class="bg-red-500"`); 74 | 75 | $this->assertStringNotContainsString('Ничего не найдено', $response->content()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /tests/Feature/MigrationsTest.php: -------------------------------------------------------------------------------- 1 | expectNotToPerformAssertions(); 16 | 17 | Artisan::call('migrate', ['--path' => 'database/migrations/tasks']); 18 | } 19 | 20 | public function test_tables_exists(): void 21 | { 22 | $this->assertTrue(Schema::hasTable('categories')); 23 | $this->assertTrue(Schema::hasTable('articles')); 24 | $this->assertTrue(Schema::hasTable('article_category')); 25 | } 26 | 27 | public function test_columns_exists(): void 28 | { 29 | $this->assertTrue(Schema::hasColumn('categories', 'title')); 30 | 31 | $this->assertTrue(Schema::hasColumns('articles', ['name', 'description', 'active', 'main'])); 32 | } 33 | 34 | public function test_soft_delete(): void 35 | { 36 | $this->assertTrue(Schema::hasColumns('articles', ['deleted_at'])); 37 | } 38 | 39 | public function test_timestamps(): void 40 | { 41 | $this->assertTrue(Schema::hasColumns('articles', ['created_at', 'updated_at'])); 42 | } 43 | 44 | public function test_default_nullable(): void 45 | { 46 | $article = Article::factory()->create(['name' => null]); 47 | 48 | $this->assertNull($article->name); 49 | } 50 | 51 | public function test_relation_table(): void 52 | { 53 | $categories = Category::factory()->count(3); 54 | 55 | $article = Article::factory()->has($categories)->create(); 56 | 57 | $this->assertEquals($article->categories->count(), 3); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/Feature/ModelTest.php: -------------------------------------------------------------------------------- 1 | 'Test']; 16 | 17 | Item::create($item); 18 | 19 | $this->assertDatabaseHas('products', $item); 20 | } 21 | 22 | public function test_task_2(): void 23 | { 24 | $item1 = Item::factory()->create(['active' => true, 'created_at' => now()->subMinutes(5)]); 25 | $item2 = Item::factory()->create(['active' => true, 'created_at' => now()->subMinutes(4)]); 26 | $item3 = Item::factory()->create(['active' => false, 'created_at' => now()->subMinutes(3)]); 27 | $item4 = Item::factory()->create(['active' => true, 'created_at' => now()->subMinutes(2)]); 28 | $item5 = Item::factory()->create(['active' => true, 'created_at' => now()->subMinute()]); 29 | 30 | $response = $this->get('/eloquent/task2'); 31 | 32 | $response->assertDontSee($item1->title); 33 | $response->assertDontSee($item3->title); 34 | 35 | $response->assertSee('1.' . $item5->title); 36 | $response->assertSee('2.' . $item4->title); 37 | $response->assertSee('3.' . $item2->title); 38 | } 39 | 40 | public function test_task_3(): void 41 | { 42 | $item1 = Item::factory()->create(['active' => true]); 43 | $item2 = Item::factory()->create(['active' => false]); 44 | 45 | $response = $this->get('/eloquent/task3'); 46 | 47 | $response->assertSee($item1->title); 48 | $response->assertDontSee($item2->title); 49 | } 50 | 51 | public function test_task_4(): void 52 | { 53 | $response = $this->get('/eloquent/task4/1'); 54 | $response->assertStatus(404); 55 | 56 | $item = Item::factory()->create(); 57 | $response = $this->get('/eloquent/task4/' . $item->id); 58 | $response->assertStatus(200); 59 | $response->assertViewHas('product', $item); 60 | } 61 | 62 | public function test_task_5(): void 63 | { 64 | $response = $this->post('/eloquent/task5', ['title' => 'Test']); 65 | $response->assertRedirect(); 66 | $this->assertDatabaseHas('products', ['title' => 'Test']); 67 | } 68 | 69 | public function test_task_6(): void 70 | { 71 | $item = new Item(); 72 | $item->title = 'Old title'; 73 | $item->save(); 74 | 75 | $this->assertDatabaseHas('products', ['title' => 'Old title']); 76 | 77 | $response = $this->post('/eloquent/task6/' . $item->id, ['title' => 'New title']); 78 | $response->assertRedirect(); 79 | 80 | $this->assertDatabaseMissing('products', ['title' => 'Old title']); 81 | $this->assertDatabaseHas('products', ['title' => 'New title']); 82 | } 83 | 84 | public function test_task_7(): void 85 | { 86 | $products = Item::factory(4)->create(); 87 | $this->assertDatabaseCount('products', 4); 88 | 89 | $response = $this->delete('/eloquent/task7', [ 90 | 'products' => $products->pluck('id', 'id') 91 | ]); 92 | 93 | $response->assertRedirect(); 94 | $this->assertDatabaseCount('products', 0); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /tests/Feature/RouteTest.php: -------------------------------------------------------------------------------- 1 | get('/hello'); 17 | $response->assertViewIs('hello'); 18 | } 19 | 20 | public function test_task_2(): void 21 | { 22 | $response = $this->get('/'); 23 | $response->assertViewIs('welcome'); 24 | $response->assertViewHas('title', 'Welcome'); 25 | } 26 | 27 | public function test_task_3(): void 28 | { 29 | $response = $this->get(route('contact')); 30 | $response->assertViewIs('pages.contact'); 31 | } 32 | 33 | public function test_task_4(): void 34 | { 35 | $user = User::factory()->create(); 36 | 37 | $response = $this->get("/users/{$user->id}"); 38 | 39 | $response->assertOk(); 40 | $response->assertViewIs('users.show'); 41 | } 42 | 43 | public function test_task_5(): void 44 | { 45 | $user = User::factory()->create(); 46 | 47 | $response = $this->get("/users/bind/{$user->id}"); 48 | 49 | $response->assertOk(); 50 | $response->assertViewIs('users.show'); 51 | } 52 | 53 | public function test_tasks_4_5_notfound(): void 54 | { 55 | $response = $this->get('/user/test'); 56 | $response->assertNotFound(); 57 | } 58 | 59 | public function test_task_6(): void 60 | { 61 | $response = $this->get('/bad'); 62 | 63 | $response->assertRedirect('/good'); 64 | } 65 | 66 | public function test_task_7(): void 67 | { 68 | $user = User::factory()->create(); 69 | 70 | $response = $this->get('/users_crud'); 71 | 72 | $response->assertViewIs('users.index'); 73 | $response->assertViewHas('users'); 74 | 75 | $response = $this->get("/users_crud/{$user->id}"); 76 | 77 | $response->assertViewIs('users.show'); 78 | $response->assertViewHas('user'); 79 | 80 | $response = $this->get('/users_crud/create'); 81 | 82 | $response->assertViewIs('users.form'); 83 | 84 | $response = $this->get("/users_crud/{$user->id}/edit"); 85 | 86 | $response->assertViewIs('users.form'); 87 | 88 | $response = $this->post('/users_crud', $this->getUserRequestData()); 89 | 90 | $response->assertRedirect('/users_crud'); 91 | 92 | $response = $this->put("/users_crud/{$user->id}", $this->getUserRequestData()); 93 | 94 | $response->assertRedirect('/users_crud'); 95 | 96 | $response = $this->delete("/users_crud/{$user->id}"); 97 | 98 | $response->assertRedirect('/users_crud'); 99 | } 100 | 101 | public function test_tasks_8_12(): void 102 | { 103 | $response = $this->get('/dashboard/admin'); 104 | $response->assertViewIs('welcome'); 105 | 106 | $response = $this->post('/dashboard/admin/post'); 107 | $response->assertViewIs('welcome'); 108 | $response->assertStatus(200); 109 | 110 | $response = $this->get('/security/admin/auth'); 111 | $response->assertRedirect('login'); 112 | 113 | $user = User::factory()->create(); 114 | 115 | $response = $this->actingAs($user)->get('/security/admin/auth'); 116 | $response->assertStatus(200); 117 | } 118 | 119 | public function test_task_13(): void 120 | { 121 | $userAuth = User::factory()->create(); 122 | 123 | $response = $this->actingAs($userAuth)->get('/api/v1/users'); 124 | $response->assertOk(); 125 | 126 | $data = $this->getUserRequestData(); 127 | $response = $this->actingAs($userAuth)->post('/api/v1/users', $data); 128 | $response->assertCreated(); 129 | $this->assertDatabaseHas(User::class, $data); 130 | 131 | $user = User::factory()->create(); 132 | $data = $this->getUserRequestData(); 133 | $response = $this->actingAs($userAuth)->put('/api/v1/users/' . $user->id, $data); 134 | $response->assertOk(); 135 | $this->assertDatabaseHas(User::class, $data); 136 | 137 | $data = $this->getUserRequestData(); 138 | $response = $this->actingAs($userAuth)->delete('/api/v1/users/' . $user->id); 139 | $response->assertNoContent(); 140 | $this->assertDatabaseMissing(User::class, $data); 141 | } 142 | 143 | private function getUserRequestData() 144 | { 145 | return [ 146 | 'name' => 'Name ' . random_int(1, 1000), 147 | 'email' => uniqid() . '@example.com', 148 | 'password' => Hash::make('123'), 149 | ]; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /tests/Feature/ValidationTest.php: -------------------------------------------------------------------------------- 1 | post('/items', ['title' => 'Testing']); 16 | 17 | $response->assertSessionDoesntHaveErrors(); 18 | 19 | $response = $this->post('/items', []); 20 | 21 | $response->assertSessionHasErrors('title'); 22 | 23 | $response = $this->post('/items', ['title' => 'T']); 24 | 25 | $response->assertSessionHasErrors('title'); 26 | 27 | $response = $this->post('/items', ['title' => 'Testing Testing Testing Testing Testing']); 28 | 29 | $response->assertSessionHasErrors('title'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 |