-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from mettle/feature/delete-draft-messages
[FEATURE] Delete draft messages
- Loading branch information
Showing
8 changed files
with
164 additions
and
1 deletion.
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
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
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
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
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sendportal\Base\Policies; | ||
|
||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
use Illuminate\Auth\Access\Response; | ||
use Sendportal\Base\Models\Message; | ||
use Sendportal\Base\Models\User; | ||
|
||
class MessagePolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
/** | ||
* Determine whether the user can delete the model. | ||
* | ||
* @param User $user | ||
* @param Message $message | ||
* @return Response | ||
*/ | ||
public function delete(User $user, Message $message) | ||
{ | ||
return is_null($message->sent_at) | ||
? Response::allow() | ||
: Response::deny(__('A sent message cannot be deleted')); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
|
||
namespace Sendportal\Base\Providers; | ||
|
||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; | ||
use Sendportal\Base\Models\Message; | ||
use Sendportal\Base\Policies\MessagePolicy; | ||
|
||
class AuthServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* The policy mappings for the application. | ||
* | ||
* @var array | ||
*/ | ||
protected $policies = [ | ||
Message::class => MessagePolicy::class | ||
]; | ||
|
||
/** | ||
* Register any authentication / authorization services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->registerPolicies(); | ||
|
||
// | ||
} | ||
} |
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
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