コード例 #1
0
ファイル: MessageController.php プロジェクト: xinray/html-css
	public function supply($id){
		$supply = Supply::find($id);

		if($supply == null){
			return API::error([1002, '没有该供应信息']);
		}

		$use = User::user();
		if ($supply->user_id == $user->id) {
            return API::error([1003, '不能给自己创建的供应发送留言']);
        }

        $message = Message::create([
        	'user_id'   => $user->id,
            'type'      => 'supply',
            'supply_id' => $supply->id,
            'demand_id' => null,
            'title'     => request('title'),
        ]);

        if ($message == null) {
            return API::error([1004, '发送意向失败']);
        }

        return API::success();
	}
コード例 #2
0
    public function supply($id)
    {
        $supply = Supply::find($id);
        if ($supply == null) {
            return API::error([1002, '没有该供应信息']);
        }

        $user = User::user();
        if ($supply->user_id == $user->id) {
            return API::error([1003, '不能给自己创建的供应发送意见']);
        }

        $coop = Cooperation::create([
            'user_send' => $user->id,
            'user_recv' => $supply->user_id,
            'type'      => 'supply',
            'supply_id' => $supply->id,
            'demand_id' => null,
            'phone'     => request('phone'),
            'contacts'  => request('contacts'),
            'content'   => request('content'),
        ]);

        if ($coop == null) {
            return API::error([1004, '发送意向失败']);
        }

        return API::success();
    }