-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\Curso; | ||
use App\Models\User; | ||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
|
||
class CursoPolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
/** | ||
* Determine whether the user can create models. | ||
* | ||
* @param \App\Models\User $user | ||
* @return mixed | ||
*/ | ||
public function create(User $user) | ||
{ | ||
return $user->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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Database\Factories; | ||
|
||
use App\Models\Curso; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class CursoFactory extends Factory | ||
{ | ||
/** | ||
* The name of the factory's corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = Curso::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
'name' => substr($this->faker->sentence(2), 0, -1), | ||
'description' => $this->faker->paragraph, | ||
]; | ||
} | ||
} |