public function demand($id) { $demand = Demand::find($id); if ($demand == null) { return API::error([1002, '没有该需求信息']); } $user = User::user(); if ($demand->user_id == $user->id) { return API::error([1003, '不能给自己创建的需求发送意见']); } $coop = Cooperation::create([ 'user_send' => $user->id, 'user_recv' => $demand->user_id, 'type' => 'demand', 'demand_id' => $demand->id, 'supply_id' => null, 'phone' => request('phone'), 'contacts' => request('contacts'), 'content' => request('content'), ]); if ($coop == null) { return API::error([1004, '发送意向失败']); } return API::success(); }