Archived
feat: approve/reject quotes
This commit is contained in:
1 parent
a918600813
commit
1833146158
10 files changed
+108
-29
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RequestedQuote extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'quote',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
public function approve(): void
|
||||
{
|
||||
// TODO: we'll probs want to log who approved this quote
|
||||
Quote::create([
|
||||
'quote' => $this->quote,
|
||||
]);
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
public function reject(): void
|
||||
{
|
||||
// TODO: we'll probs want to log who reject this quote
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RequestedQuotes extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'quote',
|
||||
'user_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class RequestQuotePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function approve(): bool
|
||||
{
|
||||
return auth()->user()->is_admin;
|
||||
}
|
||||
|
||||
public function reject(): bool
|
||||
{
|
||||
return auth()->user()->is_admin;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use App\Models\RequestedQuote;
|
||||
use App\Policies\RequestQuotePolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
@@ -13,6 +15,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
RequestedQuote::class => RequestQuotePolicy::class,
|
||||
//
|
||||
];
|
||||
|
||||
|
||||
Reference in new issue
Block a user