From 315383f5a681e5a7fa6b686a60cce3b3ce4cebbe Mon Sep 17 00:00:00 2001 From: Mali Oz Date: Fri, 26 Jul 2024 16:28:05 -0300 Subject: [PATCH] curso factory and policy --- app/Policies/CursoPolicy.php | 47 +++++++++++++++++++++++++++++ database/factories/CursoFactory.php | 29 ++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 app/Policies/CursoPolicy.php create mode 100644 database/factories/CursoFactory.php diff --git a/app/Policies/CursoPolicy.php b/app/Policies/CursoPolicy.php new file mode 100644 index 0000000..92ad4ca --- /dev/null +++ b/app/Policies/CursoPolicy.php @@ -0,0 +1,47 @@ +isAdmin(); + } + + /** + * Determine whether the user can update the model. + * + * @param \App\Models\User $user + * @param \App\Models\Curso $curso + * @return mixed + */ + public function edit(User $user, Curso $curso) + { + return $user->isAdmin(); + } + + /** + * Determine whether the user can delete the model. + * + * @param \App\Models\User $user + * @param \App\Models\Curso $curso + * @return mixed + */ + public function delete(User $user, Curso $curso) + { + return $user->isAdmin(); + } +} diff --git a/database/factories/CursoFactory.php b/database/factories/CursoFactory.php new file mode 100644 index 0000000..76dc47d --- /dev/null +++ b/database/factories/CursoFactory.php @@ -0,0 +1,29 @@ + substr($this->faker->sentence(2), 0, -1), + 'description' => $this->faker->paragraph, + ]; + } +}