From 79413b416dca55b9d1f29500ad9e9f1e8ca0f1ac Mon Sep 17 00:00:00 2001 From: FAROHE soheyb Date: Fri, 9 Feb 2024 22:42:50 +0100 Subject: [PATCH] my solution --- app/Http/Controllers/CountryController.php | 2 +- app/Http/Controllers/ProjectController.php | 7 + app/Http/Controllers/UserController.php | 5 +- app/Models/Attachment.php | 1 + app/Models/Comment.php | 4 + app/Models/Role.php | 2 +- app/Models/Task.php | 6 +- app/Models/Team.php | 7 +- app/Models/User.php | 12 +- composer.json | 1 + composer.lock | 154 +++++++++- config/debugbar.php | 281 ++++++++++++++++++ .../2021_11_22_050733_create_tasks_table.php | 8 +- ...021_11_22_052704_create_comments_table.php | 3 +- ..._11_22_054017_create_users_roles_table.php | 2 + ...2_061411_add_country_id_to_teams_table.php | 5 +- ...1_11_22_061647_add_size_to_teams_table.php | 2 +- database/seeders/DatabaseSeeder.php | 2 +- resources/views/tasks/index.blade.php | 3 +- storage/debugbar/.gitignore | 2 + tests/Feature/RelationshipsTest.php | 3 +- 21 files changed, 495 insertions(+), 17 deletions(-) create mode 100644 config/debugbar.php create mode 100644 storage/debugbar/.gitignore diff --git a/app/Http/Controllers/CountryController.php b/app/Http/Controllers/CountryController.php index 2b9be507..e0cf38c3 100644 --- a/app/Http/Controllers/CountryController.php +++ b/app/Http/Controllers/CountryController.php @@ -9,7 +9,7 @@ class CountryController extends Controller public function index() { // TASK: load the relationship average of team size - $countries = Country::all(); + $countries = Country::withAvg('teams', 'size')->get(); return view('countries.index', compact('countries')); } diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index e04fb1a6..ab4b7947 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class ProjectController extends Controller { @@ -10,7 +11,13 @@ public function store(Request $request) { // TASK: Add one sentence to save the project to the logged-in user // by $request->project_id and with $request->start_date parameter + // and return 'Success' if the project is saved successfully + $request->validate([ + 'project_id' => 'required|integer', + 'start_date' => 'required|date', + ]); + Auth::user()->projects()->attach($request->project_id, ['start_date' => $request->start_date]); return 'Success'; } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 7ae1d3d6..bf4df7be 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -8,7 +8,10 @@ class UserController extends Controller { public function index() { - $users = User::all(); + //the list should show only the users with at least one project + // + + $users = User::has('projects')->get(); return view('users.index', compact('users')); } diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index 158b6470..b899a4c4 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -14,5 +14,6 @@ class Attachment extends Model public function attachable() { // TASK: fill in the code to make it work + return $this->morphTo(); } } diff --git a/app/Models/Comment.php b/app/Models/Comment.php index aa54d5b2..94df51f6 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -15,4 +15,8 @@ public function task() { return $this->belongsTo(Task::class); } + public function attachment(): MorphMany + { + return $this->morphMany(Attachment::class, 'attachable'); + } } diff --git a/app/Models/Role.php b/app/Models/Role.php index c2f3fc89..24099baa 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -14,6 +14,6 @@ class Role extends Model public function users() { // TASK: fix this by adding a parameter - return $this->belongsToMany(User::class); + return $this->belongsToMany(User::class, 'users_roles'); } } diff --git a/app/Models/Task.php b/app/Models/Task.php index 01f6912d..049817ea 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -13,6 +13,10 @@ class Task extends Model public function user() { - return $this->belongsTo(User::class, 'users_id'); + return $this->belongsTo(User::class); + } + public function attachment(): MorphMany + { + return $this->morphMany(Attachment::class, 'attachable'); } } diff --git a/app/Models/Team.php b/app/Models/Team.php index 13969525..a96634c1 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -14,7 +14,12 @@ class Team extends Model public function users() { // TASK: fix this by adding some extra code - return $this->belongsToMany(User::class); + return $this->belongsToMany(User::class)->withPivot('position')->withTimestamps(); + + } + public function country() + { + return $this->belongsTo(Country::class); } } diff --git a/app/Models/User.php b/app/Models/User.php index 3d7facd2..c2c98d19 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -12,6 +12,8 @@ class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; + + protected $table = 'users'; /** * The attributes that are mass assignable. * @@ -50,11 +52,19 @@ public function tasks() public function comments() { - // TASK: add the code here for two-level relationship + return $this->hasManyThrough(Comment::class, Task::class); + } + public function Roles() + { + return $this->belongsToMany(Role::class, 'users_roles'); } public function projects() { return $this->belongsToMany(Project::class)->withPivot('start_date'); } + public function teams() + { + return $this->belongsToMany(Team::class)->withPivot('position')->withTimestamps(); + } } diff --git a/composer.json b/composer.json index f8de1b42..044faf92 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "laravel/tinker": "^2.8" }, "require-dev": { + "barryvdh/laravel-debugbar": "^3.9", "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.0", "laravel/sail": "^1.18", diff --git a/composer.lock b/composer.lock index b4169e3d..34ea93eb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "121ea3a2fffe49b3ef9aa4d064b28c19", + "content-hash": "f1d686884d4b3e8217805e54e9bfe92d", "packages": [ { "name": "brick/math", @@ -5409,6 +5409,90 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.9.2", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "bfd0131c146973cab164e50f5cdd8a67cc60cab1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/bfd0131c146973cab164e50f5cdd8a67cc60cab1", + "reference": "bfd0131c146973cab164e50f5cdd8a67cc60cab1", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10", + "illuminate/session": "^9|^10", + "illuminate/support": "^9|^10", + "maximebf/debugbar": "^1.18.2", + "php": "^8.0", + "symfony/finder": "^6" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^5|^6|^7|^8", + "phpunit/phpunit": "^8.5.30|^9.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.8-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + } + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.9.2" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2023-08-25T18:43:57+00:00" + }, { "name": "fakerphp/faker", "version": "v1.21.0", @@ -5726,6 +5810,72 @@ }, "time": "2023-02-08T20:22:21+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.19.1", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "03dd40a1826f4d585ef93ef83afa2a9874a00523" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/03dd40a1826f4d585ef93ef83afa2a9874a00523", + "reference": "03dd40a1826f4d585ef93ef83afa2a9874a00523", + "shasum": "" + }, + "require": { + "php": "^7.1|^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6" + }, + "require-dev": { + "phpunit/phpunit": ">=7.5.20 <10.0", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "support": { + "issues": "https://github.com/maximebf/php-debugbar/issues", + "source": "https://github.com/maximebf/php-debugbar/tree/v1.19.1" + }, + "time": "2023-10-12T08:10:52+00:00" + }, { "name": "mockery/mockery", "version": "1.5.1", @@ -7814,5 +7964,5 @@ "php": "^8.1" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/config/debugbar.php b/config/debugbar.php new file mode 100644 index 00000000..0a947cc1 --- /dev/null +++ b/config/debugbar.php @@ -0,0 +1,281 @@ + env('DEBUGBAR_ENABLED', true), + 'except' => [ + 'telescope*', + 'horizon*', + ], + + /* + |-------------------------------------------------------------------------- + | Storage settings + |-------------------------------------------------------------------------- + | + | DebugBar stores data for session/ajax requests. + | You can disable this, so the debugbar stores data in headers/session, + | but this can cause problems with large data collectors. + | By default, file storage (in the storage folder) is used. Redis and PDO + | can also be used. For PDO, run the package migrations first. + | + | Warning: Enabling storage.open will allow everyone to access previous + | request, do not enable open storage in publicly available environments! + | Specify a callback if you want to limit based on IP or authentication. + */ + 'storage' => [ + 'enabled' => true, + 'open' => env('DEBUGBAR_OPEN_STORAGE', false), // bool/callback. + 'driver' => 'file', // redis, file, pdo, socket, custom + 'path' => storage_path('debugbar'), // For file driver + 'connection' => null, // Leave null for default connection (Redis/PDO) + 'provider' => '', // Instance of StorageInterface for custom driver + 'hostname' => '127.0.0.1', // Hostname to use with the "socket" driver + 'port' => 2304, // Port to use with the "socket" driver + ], + + /* + |-------------------------------------------------------------------------- + | Editor + |-------------------------------------------------------------------------- + | + | Choose your preferred editor to use when clicking file name. + | + | Supported: "phpstorm", "vscode", "vscode-insiders", "vscode-remote", + | "vscode-insiders-remote", "vscodium", "textmate", "emacs", + | "sublime", "atom", "nova", "macvim", "idea", "netbeans", + | "xdebug", "espresso" + | + */ + + 'editor' => env('DEBUGBAR_EDITOR', 'phpstorm'), + + /* + |-------------------------------------------------------------------------- + | Remote Path Mapping + |-------------------------------------------------------------------------- + | + | If you are using a remote dev server, like Laravel Homestead, Docker, or + | even a remote VPS, it will be necessary to specify your path mapping. + | + | Leaving one, or both of these, empty or null will not trigger the remote + | URL changes and Debugbar will treat your editor links as local files. + | + | "remote_sites_path" is an absolute base path for your sites or projects + | in Homestead, Vagrant, Docker, or another remote development server. + | + | Example value: "/home/vagrant/Code" + | + | "local_sites_path" is an absolute base path for your sites or projects + | on your local computer where your IDE or code editor is running on. + | + | Example values: "/Users//Code", "C:\Users\\Documents\Code" + | + */ + + 'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH', ''), + 'local_sites_path' => env('DEBUGBAR_LOCAL_SITES_PATH', ''), + + /* + |-------------------------------------------------------------------------- + | Vendors + |-------------------------------------------------------------------------- + | + | Vendor files are included by default, but can be set to false. + | This can also be set to 'js' or 'css', to only include javascript or css vendor files. + | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files) + | and for js: jquery and highlight.js + | So if you want syntax highlighting, set it to true. + | jQuery is set to not conflict with existing jQuery scripts. + | + */ + + 'include_vendors' => true, + + /* + |-------------------------------------------------------------------------- + | Capture Ajax Requests + |-------------------------------------------------------------------------- + | + | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors), + | you can use this option to disable sending the data through the headers. + | + | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools. + | + | Note for your request to be identified as ajax requests they must either send the header + | X-Requested-With with the value XMLHttpRequest (most JS libraries send this), or have application/json as a Accept header. + */ + + 'capture_ajax' => true, + 'add_ajax_timing' => false, + + /* + |-------------------------------------------------------------------------- + | Custom Error Handler for Deprecated warnings + |-------------------------------------------------------------------------- + | + | When enabled, the Debugbar shows deprecated warnings for Symfony components + | in the Messages tab. + | + */ + 'error_handler' => false, + + /* + |-------------------------------------------------------------------------- + | Clockwork integration + |-------------------------------------------------------------------------- + | + | The Debugbar can emulate the Clockwork headers, so you can use the Chrome + | Extension, without the server-side code. It uses Debugbar collectors instead. + | + */ + 'clockwork' => false, + + /* + |-------------------------------------------------------------------------- + | DataCollectors + |-------------------------------------------------------------------------- + | + | Enable/disable DataCollectors + | + */ + + 'collectors' => [ + 'phpinfo' => true, // Php version + 'messages' => true, // Messages + 'time' => true, // Time Datalogger + 'memory' => true, // Memory usage + 'exceptions' => true, // Exception displayer + 'log' => true, // Logs from Monolog (merged in messages if enabled) + 'db' => true, // Show database (PDO) queries and bindings + 'views' => true, // Views with their data + 'route' => true, // Current route information + 'auth' => false, // Display Laravel authentication status + 'gate' => true, // Display Laravel Gate checks + 'session' => true, // Display session data + 'symfony_request' => true, // Only one can be enabled.. + 'mail' => true, // Catch mail messages + 'laravel' => false, // Laravel version and environment + 'events' => false, // All events fired + 'default_request' => false, // Regular or special Symfony request logger + 'logs' => false, // Add the latest log messages + 'files' => false, // Show the included files + 'config' => false, // Display config settings + 'cache' => false, // Display cache events + 'models' => true, // Display models + 'livewire' => true, // Display Livewire (when available) + ], + + /* + |-------------------------------------------------------------------------- + | Extra options + |-------------------------------------------------------------------------- + | + | Configure some DataCollectors + | + */ + + 'options' => [ + 'auth' => [ + 'show_name' => true, // Also show the users name/email in the debugbar + ], + 'db' => [ + 'with_params' => true, // Render SQL with the parameters substituted + 'backtrace' => true, // Use a backtrace to find the origin of the query in your files. + 'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults) + 'timeline' => false, // Add the queries to the timeline + 'duration_background' => true, // Show shaded background on each query relative to how long it took to execute. + 'explain' => [ // Show EXPLAIN output on queries + 'enabled' => false, + 'types' => ['SELECT'], // Deprecated setting, is always only SELECT + ], + 'hints' => false, // Show hints for common mistakes + 'show_copy' => false, // Show copy button next to the query, + 'slow_threshold' => false, // Only track queries that last longer than this time in ms + ], + 'mail' => [ + 'full_log' => false, + ], + 'views' => [ + 'timeline' => false, // Add the views to the timeline (Experimental) + 'data' => false, //Note: Can slow down the application, because the data can be quite large.. + 'exclude_paths' => [], // Add the paths which you don't want to appear in the views + ], + 'route' => [ + 'label' => true, // show complete route on bar + ], + 'logs' => [ + 'file' => null, + ], + 'cache' => [ + 'values' => true, // collect cache values + ], + ], + + /* + |-------------------------------------------------------------------------- + | Inject Debugbar in Response + |-------------------------------------------------------------------------- + | + | Usually, the debugbar is added just before , by listening to the + | Response after the App is done. If you disable this, you have to add them + | in your template yourself. See http://phpdebugbar.com/docs/rendering.html + | + */ + + 'inject' => true, + + /* + |-------------------------------------------------------------------------- + | DebugBar route prefix + |-------------------------------------------------------------------------- + | + | Sometimes you want to set route prefix to be used by DebugBar to load + | its resources from. Usually the need comes from misconfigured web server or + | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97 + | + */ + 'route_prefix' => '_debugbar', + + /* + |-------------------------------------------------------------------------- + | DebugBar route domain + |-------------------------------------------------------------------------- + | + | By default DebugBar route served from the same domain that request served. + | To override default domain, specify it as a non-empty value. + */ + 'route_domain' => null, + + /* + |-------------------------------------------------------------------------- + | DebugBar theme + |-------------------------------------------------------------------------- + | + | Switches between light and dark theme. If set to auto it will respect system preferences + | Possible values: auto, light, dark + */ + 'theme' => env('DEBUGBAR_THEME', 'auto'), + + /* + |-------------------------------------------------------------------------- + | Backtrace stack limit + |-------------------------------------------------------------------------- + | + | By default, the DebugBar limits the number of frames returned by the 'debug_backtrace()' function. + | If you need larger stacktraces, you can increase this number. Setting it to 0 will result in no limit. + */ + 'debug_backtrace_limit' => 50, +]; diff --git a/database/migrations/2021_11_22_050733_create_tasks_table.php b/database/migrations/2021_11_22_050733_create_tasks_table.php index c136b799..96c8c304 100644 --- a/database/migrations/2021_11_22_050733_create_tasks_table.php +++ b/database/migrations/2021_11_22_050733_create_tasks_table.php @@ -16,8 +16,8 @@ public function up() Schema::create('tasks', function (Blueprint $table) { $table->id(); $table->string('name'); - $table->unsignedBigInteger('users_id')->nullable(); - $table->foreign('users_id')->references('id')->on('users'); + $table->unsignedBigInteger('user_id')->nullable(); + $table->foreign('user_id')->references('id')->on('users'); $table->timestamps(); }); } @@ -29,6 +29,10 @@ public function up() */ public function down() { + DB::statement('SET FOREIGN_KEY_CHECKS = 0'); Schema::dropIfExists('tasks'); + DB::statement('SET FOREIGN_KEY_CHECKS = 1'); + + } } diff --git a/database/migrations/2021_11_22_052704_create_comments_table.php b/database/migrations/2021_11_22_052704_create_comments_table.php index fc4e2f35..49426f89 100644 --- a/database/migrations/2021_11_22_052704_create_comments_table.php +++ b/database/migrations/2021_11_22_052704_create_comments_table.php @@ -28,7 +28,8 @@ public function up() * @return void */ public function down() - { + { DB::statement('SET FOREIGN_KEY_CHECKS = 0'); Schema::dropIfExists('comments'); + DB::statement('SET FOREIGN_KEY_CHECKS = 1'); } } diff --git a/database/migrations/2021_11_22_054017_create_users_roles_table.php b/database/migrations/2021_11_22_054017_create_users_roles_table.php index da1d63d1..d8311ab1 100644 --- a/database/migrations/2021_11_22_054017_create_users_roles_table.php +++ b/database/migrations/2021_11_22_054017_create_users_roles_table.php @@ -16,6 +16,8 @@ public function up() Schema::create('users_roles', function (Blueprint $table) { $table->foreignId('user_id')->constrained(); $table->foreignId('role_id')->constrained(); + $table->primary(['user_id', 'role_id']); + }); } diff --git a/database/migrations/2021_11_22_061411_add_country_id_to_teams_table.php b/database/migrations/2021_11_22_061411_add_country_id_to_teams_table.php index 4edb9986..ad2c2eb4 100644 --- a/database/migrations/2021_11_22_061411_add_country_id_to_teams_table.php +++ b/database/migrations/2021_11_22_061411_add_country_id_to_teams_table.php @@ -26,7 +26,8 @@ public function up() public function down() { Schema::table('teams', function (Blueprint $table) { - // - }); + $table->dropForeign(['country_id']); + $table->dropColumn('country_id'); + }); } } diff --git a/database/migrations/2021_11_22_061647_add_size_to_teams_table.php b/database/migrations/2021_11_22_061647_add_size_to_teams_table.php index 28011bc2..dcafab32 100644 --- a/database/migrations/2021_11_22_061647_add_size_to_teams_table.php +++ b/database/migrations/2021_11_22_061647_add_size_to_teams_table.php @@ -26,7 +26,7 @@ public function up() public function down() { Schema::table('teams', function (Blueprint $table) { - // + $table->dropColumn('size'); }); } } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 57b73b54..6c2afc9e 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,6 +13,6 @@ class DatabaseSeeder extends Seeder */ public function run() { - // \App\Models\User::factory(10)->create(); + \App\Models\User::factory(1)->create(); } } diff --git a/resources/views/tasks/index.blade.php b/resources/views/tasks/index.blade.php index 8d229417..dc20f6e5 100644 --- a/resources/views/tasks/index.blade.php +++ b/resources/views/tasks/index.blade.php @@ -1,5 +1,6 @@
    @foreach ($tasks as $task) -
  • {{ $task->name }} ({{ $task->user->name }})
  • +
  • {{ $task->name }} ({{ $task->user ? $task->user->name : '' }})
  • @endforeach +
diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Feature/RelationshipsTest.php b/tests/Feature/RelationshipsTest.php index c7bc63f1..4e76eceb 100644 --- a/tests/Feature/RelationshipsTest.php +++ b/tests/Feature/RelationshipsTest.php @@ -34,6 +34,7 @@ public function test_task_with_no_user() Task::create(['name' => 'Some task']); $response = $this->get('/tasks'); + $response->assertSeeText('Some task'); $response->assertStatus(200); } @@ -43,7 +44,7 @@ public function test_show_users_comments() { $user = User::factory()->create(); $task = Task::create([ - 'users_id' => $user->id, + 'user_id' => $user->id, 'name' => 'Some task' ]); Comment::create([