修复 路由问题
This commit is contained in:
parent
386a3e7f20
commit
2a20a17bac
@ -2,12 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers\Remote\Host;
|
||||
|
||||
use App\Models\Host;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use App\Models\User\Task;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class TaskController extends Controller
|
||||
{
|
||||
@ -63,8 +60,10 @@ public function update(Request $request, Task $task)
|
||||
'status' => 'sometimes|in:pending,processing,need_operation,done,success,failed,error,canceled',
|
||||
]);
|
||||
|
||||
|
||||
$task->update($request->all());
|
||||
|
||||
|
||||
return $this->updated($task);
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,17 @@ class Task extends Model
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public function scopeUser($query) {
|
||||
// key type string
|
||||
protected $keyType = 'string';
|
||||
|
||||
public function scopeUser($query)
|
||||
{
|
||||
return $query->where('user_id', auth()->id());
|
||||
}
|
||||
|
||||
|
||||
public function host() {
|
||||
public function host()
|
||||
{
|
||||
return $this->belongsTo(Host::class);
|
||||
}
|
||||
|
||||
@ -43,6 +48,7 @@ protected static function boot()
|
||||
// id 为 uuid
|
||||
$model->id = Uuid::uuid4()->toString();
|
||||
|
||||
|
||||
// host_id 和 user_id 至少存在一个
|
||||
if (!$model->host_id && !$model->user_id) {
|
||||
throw new CommonException('host_id 和 user_id 至少存在一个');
|
||||
@ -51,17 +57,22 @@ protected static function boot()
|
||||
// if host_id
|
||||
if ($model->host_id) {
|
||||
$model->load('host');
|
||||
// dd($model);
|
||||
|
||||
if ($model->host === null) {
|
||||
throw new CommonException('host_id 不存在');
|
||||
}
|
||||
|
||||
// dd($model);
|
||||
|
||||
// dd($model->host_id);
|
||||
// $host = Host::where('id', $model->host_id)->first();
|
||||
|
||||
// dd($host);
|
||||
|
||||
|
||||
|
||||
$model->user_id = $model->host->user_id;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// updateing
|
||||
|
@ -70,7 +70,7 @@ private function alipayOptions()
|
||||
// $options->alipayPublicKey = Storage::get('alipayCertPublicKey_RSA2.crt');
|
||||
|
||||
//可设置异步通知接收服务地址(可选)
|
||||
$options->notifyUrl = "http://rcrmqishil.sharedwithexpose.com/api/pay/notify";
|
||||
$options->notifyUrl = route('balances.notify');
|
||||
|
||||
|
||||
return $options;
|
||||
|
@ -31,13 +31,13 @@
|
||||
$router->post('/', [
|
||||
'uses' => 'Host\TaskController@store'
|
||||
]);
|
||||
$router->get('/{tasks}', [
|
||||
$router->get('/{task}', [
|
||||
'uses' => 'Host\TaskController@show'
|
||||
]);
|
||||
$router->patch('/{tasks}', [
|
||||
$router->patch('/{task}', [
|
||||
'uses' => 'Host\TaskController@update'
|
||||
]);
|
||||
$router->delete('/{tasks}', [
|
||||
$router->delete('/{task}', [
|
||||
'uses' => 'Host\TaskController@destroy'
|
||||
]);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user