Ejemplo n.º 1
0
	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();
	}
Ejemplo n.º 2
0
    public static function createSupply()
    {
        $validator = self::validator();
        if ($validator->fails()) {
            return back()->withErrors($validator->errors())->withInput();
        }

        DB::transaction(function() use (&$personal) {
            $supply = Supply::create([
                'type_id'   => 3,
                'title'     => request('title'),
                'user_id'   => User::user()->id,
                'desc'      => request('desc'),
                'stage'     => 2,
            ]);

            $personal = new self(request()->all());

            $personal = $supply->personal()->save($personal);
        });

        if ($personal != null) {
            return redirect('user/supply');
        } else {
            return back()->withErrors('创建失败')->withInput();
        }
    }
Ejemplo n.º 3
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();
    }
Ejemplo n.º 4
0
    public function page($type)
    {
        $query = request()->except('page');

        $supplies = Supply::getPage($type);

        return view('supply.supply_page')
            ->withSupplies($supplies)
            ->withType($type)
            ->withQuery($query);
    }
Ejemplo n.º 5
0
 public function supply()
 {
     $supplies = Supply::where('user_id', User::user()->id)->orderBy('created_at', 'desc')->paginate();
     return view('user.supply')->withSupplies($supplies);
 }