-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added last rate history improved security of rates
- Loading branch information
Showing
13 changed files
with
252 additions
and
4 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
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,108 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Controllers\XController; | ||
use App\Http\Requests\RateSaveRequest; | ||
use App\Models\Access; | ||
use App\Models\Rate; | ||
use Illuminate\Http\Request; | ||
use App\Helper; | ||
use function App\Helpers\hasCreateRoute; | ||
|
||
class RateController extends XController | ||
{ | ||
|
||
// protected $_MODEL_ = Rate::class; | ||
// protected $SAVE_REQUEST = RateSaveRequest::class; | ||
|
||
protected $cols = ['rateable_type', 'rateable_id', 'rater_type', 'rater_id', 'rate','evaluation_id']; | ||
protected $extra_cols = ['id']; | ||
|
||
protected $searchable = ['rate','rateable_type','rateable_id', 'rater_type', 'rater_id']; | ||
|
||
protected $listView = 'admin.rates.rate-list'; | ||
protected $formView = 'admin.rates.rate-form'; | ||
|
||
|
||
protected $buttons = [ | ||
// 'edit' => | ||
// ['title' => "Edit", 'class' => 'btn-outline-primary', 'icon' => 'ri-edit-2-line'], | ||
// 'show' => | ||
// ['title' => "Detail", 'class' => 'btn-outline-light', 'icon' => 'ri-eye-line'], | ||
// 'destroy' => | ||
// ['title' => "Remove", 'class' => 'btn-outline-danger delete-confirm', 'icon' => 'ri-close-line'], | ||
]; | ||
|
||
|
||
public function __construct() | ||
{ | ||
parent::__construct(Rate::class, RateSaveRequest::class); | ||
} | ||
|
||
/** | ||
* @param $rate Rate | ||
* @param $request RateSaveRequest | ||
* @return Rate | ||
*/ | ||
public function save($rate, $request) | ||
{ | ||
|
||
$rate->save(); | ||
return $rate; | ||
|
||
} | ||
|
||
|
||
/** | ||
* Show the form for creating a new resource. | ||
*/ | ||
public function create() | ||
{ | ||
// | ||
return view($this->formView); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
*/ | ||
public function edit(Rate $item) | ||
{ | ||
// | ||
return view($this->formView, compact('item')); | ||
} | ||
|
||
public function bulk(Request $request) | ||
{ | ||
|
||
// dd($request->all()); | ||
$data = explode('.', $request->input('action')); | ||
$action = $data[0]; | ||
$ids = $request->input('id'); | ||
switch ($action) { | ||
case 'delete': | ||
$msg = __(':COUNT items deleted successfully', ['COUNT' => count($ids)]); | ||
$this->_MODEL_::destroy($ids); | ||
break; | ||
|
||
default: | ||
$msg = __('Unknown bulk action : :ACTION', ["ACTION" => $action]); | ||
} | ||
|
||
return $this->do_bulk($msg, $action, $ids); | ||
} | ||
|
||
public function destroy(Rate $item) | ||
{ | ||
return parent::delete($item); | ||
} | ||
|
||
|
||
public function update(Request $request, Rate $item) | ||
{ | ||
return $this->bringUp($request, $item); | ||
} | ||
|
||
|
||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class RateSaveRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
} |
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,42 @@ | ||
@extends('admin.templates.panel-form-template') | ||
@section('title') | ||
@if(isset($item)) | ||
{{__("Edit rate")}} [{{$item->id}}] | ||
@else | ||
{{__("Add new rate")}} | ||
@endif - | ||
@endsection | ||
@section('form') | ||
|
||
<div class="row"> | ||
<div class="col-lg-3"> | ||
|
||
@include('components.err') | ||
<div class="item-list mb-3"> | ||
<h3 class="p-3"> | ||
<i class="ri-message-3-line"></i> | ||
{{__("Tips")}} | ||
</h3> | ||
<ul> | ||
<li> | ||
{{__("Recommends")}} | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
</div> | ||
<div class="col-lg-9 ps-xl-1 ps-xxl-1"> | ||
<div class="general-form "> | ||
|
||
<h1> | ||
@if(isset($item)) | ||
{{__("Edit rate")}} [{{$item->id}}] | ||
@else | ||
{{__("Add new rate")}} | ||
@endif | ||
</h1> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
@endsection |
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,15 @@ | ||
@extends('admin.templates.panel-list-template') | ||
|
||
@section('list-title') | ||
<i class="ri-user-3-line"></i> | ||
{{__("Rates list")}} | ||
@endsection | ||
@section('title') | ||
{{__("Rates list")}} - | ||
@endsection | ||
@section('filter') | ||
{{-- Other filters --}} | ||
@endsection | ||
@section('bulk') | ||
{{-- <option value="-"> - </option> --}} | ||
@endsection |
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