1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Modules\Mini\Controllers;
- use App\Base\BaseController;
- use App\Models\User\UserAddress;
- use App\Models\User\UserFav;
- use App\Modules\Mini\Services\AddressService;
- use App\Modules\Mini\Services\CompanyService;
- use App\Modules\Mini\Services\FavService;
- use Illuminate\Support\Facades\Auth;
- class UserController extends BaseController
- {
- public function company()
- {
- $params = $this->valid([
- "name" => "required",
- "tax_no" => "",
- "department" => "",
- "tel" => "",
- "address" => "",
- "linkman" => "",
- ]);
- return $this->ok(app(CompanyService::class)->company(Auth::user(), $params));
- }
- public function fav()
- {
- $params = $this->valid([
- "page_size" => "",
- ]);
- return $this->ok(app(FavService::class)->paginate(Auth::user(), $params));
- }
- public function favDel()
- {
- $params = $this->valid([
- "ids" => "array|required",
- ]);
- return $this->ok([
- "row" => UserFav::whereIn("id", $params['ids'])->where("user_id", Auth::id())->delete(),
- ]);
- }
- public function address()
- {
- $params = $this->valid([
- "page_size" => "",
- ]);
- return $this->ok(app(AddressService::class)->paginate(Auth::user(), $params));
- }
- public function addressDel()
- {
- $params = $this->valid([
- "id" => "required",
- ]);
- $row = UserAddress::where("user_id", Auth::id())->where("id", $params['id'])->delete();
- return $this->ok([
- "row" => $row,
- ]);
- }
- public function addressStore()
- {
- $params = $this->valid([
- "id" => "int",
- "is_default" => "",
- "name" => "required",
- "address" => "required",
- 'phone' => "required",
- "area" => "required",
- ]);
- return $this->ok(app(AddressService::class)->store(Auth::user(), $params));
- }
- }
|