fix bugs
This commit is contained in:
@@ -189,51 +189,52 @@ class TaskController extends Controller
|
||||
}
|
||||
public function storeTask(Request $request)
|
||||
{
|
||||
$name = $request->name;
|
||||
$desc = $request->description_html;
|
||||
$priority = $request->priority;
|
||||
$start_date = $request->start_date;
|
||||
$target_date = $request->target_date;
|
||||
$state = $request->state;
|
||||
$assignees = $request->assignees;
|
||||
$parent = $request->parent;
|
||||
$estimate_point = $request->estimate_point;
|
||||
$created_by = User::where('user_name', $_COOKIE['user_identity'])->first()->plain_id;
|
||||
|
||||
// اگر خواستی کاربر ایجاد کننده هم اضافه کنی:
|
||||
// $created_by = User::where('user_name', $_COOKIE['user_identity'])->first()->plain_id;
|
||||
Tasks::create([
|
||||
"name" => $request->name,
|
||||
"desc" => $request->description_html,
|
||||
"priority" => $request->priority,
|
||||
"start_date" => $request->start_date,
|
||||
"target_date" => $request->target_date,
|
||||
"state" => $request->state,
|
||||
"assignees" => $request->assignees,
|
||||
"parent" => $request->parent,
|
||||
"estimate_point" => $request->estimate_point,
|
||||
|
||||
$headers = [
|
||||
'x-api-key' => 'plane_api_ec378e977ceb4bd1bbd2332855370645',
|
||||
'Content-Type' => 'application/json'
|
||||
];
|
||||
]);
|
||||
|
||||
$body = json_encode([
|
||||
"name" => $name,
|
||||
"description_html" => $desc ?: '',
|
||||
"priority" => $priority ?: 'none',
|
||||
"start_date" => $start_date ?: null,
|
||||
"target_date" => $target_date ?: null,
|
||||
"estimate_point" => $estimate_point ?: '',
|
||||
"state" => $state ?: '',
|
||||
"parent" => $parent ?: '',
|
||||
"assignees" => $assignees ?: '',
|
||||
// "labels" => $labels ?: null,
|
||||
// "created_by" => $created_by
|
||||
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
// $headers = [
|
||||
// 'x-api-key' => 'plane_api_ec378e977ceb4bd1bbd2332855370645',
|
||||
// 'Content-Type' => 'application/json'
|
||||
// ];
|
||||
//
|
||||
// $body = json_encode([
|
||||
// "name" => $name,
|
||||
// "description_html" => $desc ?: '',
|
||||
// "priority" => $priority ?: 'none',
|
||||
// "start_date" => $start_date ?: null,
|
||||
// "target_date" => $target_date ?: null,
|
||||
// "estimate_point" => $estimate_point ?: '',
|
||||
// "state" => $state ?: '',
|
||||
// "parent" => $parent ?: '',
|
||||
// "assignees" => $assignees ?: '',
|
||||
// // "labels" => $labels ?: null,
|
||||
// // "created_by" => $created_by
|
||||
// ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
//
|
||||
// $client = new Client();
|
||||
//
|
||||
// $response = $client->post(
|
||||
// 'https://api.plane.so/api/v1/workspaces/montzar/projects/c1df4085-582f-4b57-b3c6-95b7d4d19007/issues/',
|
||||
// [
|
||||
// 'headers' => $headers,
|
||||
// 'body' => $body,
|
||||
// ]
|
||||
// );
|
||||
//
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->post(
|
||||
'https://api.plane.so/api/v1/workspaces/montzar/projects/c1df4085-582f-4b57-b3c6-95b7d4d19007/issues/',
|
||||
[
|
||||
'headers' => $headers,
|
||||
'body' => $body,
|
||||
]
|
||||
);
|
||||
|
||||
$data = json_decode($response->getBody(), true);
|
||||
|
||||
// اگر میخوای بعدا داده رو ذخیره یا آپدیت کنی، میتونی اینجا صدا بزنی:
|
||||
// update_tasks($data);
|
||||
|
||||
return back()->with('message', [
|
||||
@@ -242,29 +243,29 @@ class TaskController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function webhookPlane(Request $request)
|
||||
{
|
||||
$d = $request->all();
|
||||
|
||||
// فقط وقتی تغییر state هست
|
||||
if (isset($d['event'], $d['action'], $d['data']['name'], $d['data']['state']['name'])) {
|
||||
$msg = "Event: {$d['event']}\nAction: {$d['action']}\nName: {$d['data']['name']}\nNew Status: {$d['data']['state']['name']}";
|
||||
|
||||
// ارسال به تلگرام
|
||||
Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
'botToken' => "7467099619:AAF2V6yYcbAb8oSIRSCyH5i2GKfdWVO3a7k",
|
||||
'chatId' => "-4742642674",
|
||||
'message' => $msg,
|
||||
]);
|
||||
}
|
||||
|
||||
// اگر خواستی ثبت در دیتابیس هم اضافه کنی
|
||||
// DB::table('tst')->insert([
|
||||
// 'data' => json_encode($d, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE),
|
||||
// ]);
|
||||
|
||||
return response()->json(['status' => 'ok'], 200);
|
||||
}
|
||||
// public function webhookPlane(Request $request)
|
||||
// {
|
||||
// $d = $request->all();
|
||||
//
|
||||
// // فقط وقتی تغییر state هست
|
||||
// if (isset($d['event'], $d['action'], $d['data']['name'], $d['data']['state']['name'])) {
|
||||
// $msg = "Event: {$d['event']}\nAction: {$d['action']}\nName: {$d['data']['name']}\nNew Status: {$d['data']['state']['name']}";
|
||||
//
|
||||
// // ارسال به تلگرام
|
||||
// Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
// 'botToken' => "7467099619:AAF2V6yYcbAb8oSIRSCyH5i2GKfdWVO3a7k",
|
||||
// 'chatId' => "-4742642674",
|
||||
// 'message' => $msg,
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// // اگر خواستی ثبت در دیتابیس هم اضافه کنی
|
||||
// // DB::table('tst')->insert([
|
||||
// // 'data' => json_encode($d, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE),
|
||||
// // ]);
|
||||
//
|
||||
// return response()->json(['status' => 'ok'], 200);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user