action = $action; $this->request = $request; $this->model = $seller; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(Seller $seller, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $seller = $seller->create($attributes); return $seller; } public function update(Seller $seller, array $request) { $attributes = $request; $seller->update($attributes); return $seller; } public function destroy(Seller $seller, array $request) { $seller->delete(); return $seller; } public function copy(Seller $seller, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $seller = $seller->replicate(); $seller->created_at = Carbon::now(); $seller->save(); return $seller; } for ($i = 1; $i <= $count; $i++) { $new = $seller->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $seller; } }